Skip to content

Commit

Permalink
Move CMS console commands into the CMS module
Browse files Browse the repository at this point in the history
Moved the following:
- \System\Console\ThemeInstall -> \Cms\Console\ThemeInstall
- \System\Console\ThemeRemove -> \Cms\Console\ThemeRemove
- \System\Console\ThemeList -> \Cms\Console\ThemeList
- \System\Console\ThemeUse -> \Cms\Console\ThemeUse
- \System\Console\ThemeSync -> \Cms\Console\ThemeSync
  • Loading branch information
LukeTowers committed Feb 15, 2022
1 parent 301ffd1 commit d61ac9d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 21 deletions.
4 changes: 2 additions & 2 deletions artisan
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
| loading of any of our classes manually. It's great to relax.
|
*/

Expand Down Expand Up @@ -40,7 +40,7 @@ $status = $kernel->handle(
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running. We will fire off the shutdown events
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
Expand Down
13 changes: 13 additions & 0 deletions modules/cms/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function register()
{
parent::register('cms');

$this->registerConsole();
$this->registerAssetBundles();
$this->registerComponents();
$this->registerThemeLogging();
Expand Down Expand Up @@ -67,6 +68,18 @@ public function boot()
}
}

/**
* Register command line specifics
*/
protected function registerConsole()
{
$this->registerConsoleCommand('theme.install', \Cms\Console\ThemeInstall::class);
$this->registerConsoleCommand('theme.remove', \Cms\Console\ThemeRemove::class);
$this->registerConsoleCommand('theme.list', \Cms\Console\ThemeList::class);
$this->registerConsoleCommand('theme.use', \Cms\Console\ThemeUse::class);
$this->registerConsoleCommand('theme.sync', \Cms\Console\ThemeSync::class);
}

/**
* Register asset bundles
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace System\Console;
<?php namespace Cms\Console;

use File;
use Cms\Classes\Theme;
Expand All @@ -13,7 +13,7 @@
*
* This adds a new theme by requesting it from the Winter marketplace.
*
* @package winter\wn-system-module
* @package winter\wn-cms-module
* @author Alexey Bobkov, Samuel Georges
*/
class ThemeInstall extends Command
Expand All @@ -36,6 +36,10 @@ class ThemeInstall extends Command
*/
public function handle()
{
echo 'wtf';
\Winter\Storm\Network\Http::post('https://google.com/');


$themeName = $this->argument('name');
$argDirName = $this->argument('dirName');

Expand All @@ -59,10 +63,14 @@ public function handle()

$themeDetails = $updateManager->requestThemeDetails($themeName);

dd('after requestThemeDetails');

if ($themeManager->isInstalled($themeDetails['code'])) {
return $this->error(sprintf('The theme %s is already installed.', $themeDetails['code']));
}

dd($themeName);

if (Theme::exists($themeDetails['code'])) {
return $this->error(sprintf('A theme named %s already exists.', $themeDetails['code']));
}
Expand All @@ -81,6 +89,8 @@ public function handle()
return;
}

dd($themeName);

$this->info('Downloading theme...');
$updateManager->downloadTheme($themeDetails['code'], $themeDetails['hash']);

Expand All @@ -104,12 +114,14 @@ public function handle()

$dirName = $argDirName;
}
dd($themeName);

$this->info(sprintf('The theme %s has been installed. (now %s)', $themeDetails['code'], $dirName));
}
catch (Exception $ex) {
} catch (\Throwable $ex) {
$this->error($ex->getMessage());
}

dd($themeName);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace System\Console;
<?php namespace Cms\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -11,7 +11,7 @@
*
* This lists all the available themes in the system. It also shows the active theme.
*
* @package winter\wn-system-module
* @package winter\wn-cms-module
* @author Alexey Bobkov, Samuel Georges
*/
class ThemeList extends Command
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace System\Console;
<?php namespace Cms\Console;

use Cms\Classes\Theme;
use Cms\Classes\ThemeManager;
Expand All @@ -12,7 +12,7 @@
*
* This completely deletes an existing theme, including all files and directories.
*
* @package winter\wn-system-module
* @package winter\wn-cms-module
* @author Alexey Bobkov, Samuel Georges
*/
class ThemeRemove extends Command
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace System\Console;
<?php namespace Cms\Console;

use App;
use Event;
Expand All @@ -19,7 +19,7 @@
* - --target defaults to "filesystem", the source will whichever of filesystem vs database is not the target
* - --force bypasses the confirmation request
*
* @package winter\wn-system-module
* @package winter\wn-cms-module
* @author Luke Towers
*/
class ThemeSync extends Command
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace System\Console;
<?php namespace Cms\Console;

use Cms\Classes\Theme;
use Illuminate\Console\Command;
Expand All @@ -10,7 +10,7 @@
*
* This switches the active theme to another one, saved to the database.
*
* @package winter\wn-system-module
* @package winter\wn-cms-module
* @author Alexey Bobkov, Samuel Georges
*/
class ThemeUse extends Command
Expand Down
6 changes: 0 additions & 6 deletions modules/system/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,6 @@ protected function registerConsole()
$this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh');
$this->registerConsoleCommand('plugin.rollback', 'System\Console\PluginRollback');
$this->registerConsoleCommand('plugin.list', 'System\Console\PluginList');

$this->registerConsoleCommand('theme.install', 'System\Console\ThemeInstall');
$this->registerConsoleCommand('theme.remove', 'System\Console\ThemeRemove');
$this->registerConsoleCommand('theme.list', 'System\Console\ThemeList');
$this->registerConsoleCommand('theme.use', 'System\Console\ThemeUse');
$this->registerConsoleCommand('theme.sync', 'System\Console\ThemeSync');
}

/*
Expand Down
8 changes: 7 additions & 1 deletion modules/system/classes/UpdateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -890,10 +890,16 @@ public function setNotesOutput($output)
*/
public function requestServerData($uri, $postData = [])
{
$result = Http::post($this->createServerUrl($uri), function ($http) use ($postData) {
// dd(Http::class, (new \ReflectionClass(Http::class))->getFileName());

// dd($this->createServerUrl($uri));

$result = \Winter\Storm\Network\Http::post($this->createServerUrl($uri), function ($http) use ($postData) {
$this->applyHttpAttributes($http, $postData);
});

dd($result, 'after Http::post');

if ($result->code == 404) {
throw new ApplicationException(Lang::get('system::lang.server.response_not_found'));
}
Expand Down

0 comments on commit d61ac9d

Please sign in to comment.