diff --git a/libraries/src/Application/ConsoleApplication.php b/libraries/src/Application/ConsoleApplication.php index 9c9a65ce472e7..28c7a1cb6bfc4 100644 --- a/libraries/src/Application/ConsoleApplication.php +++ b/libraries/src/Application/ConsoleApplication.php @@ -10,6 +10,7 @@ defined('JPATH_PLATFORM') or die; +use Joomla\CMS\Console; use Joomla\CMS\Input\Cli; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Console\Application; @@ -163,6 +164,25 @@ public function enqueueMessage($msg, $type = self::MSG_INFO) $this->messages[$type][] = $msg; } + /** + * Get the commands which should be registered by default to the application. + * + * @return CommandInterface[] + * + * @since __DEPLOY_VERSION__ + */ + protected function getDefaultCommands(): array + { + return array_merge( + parent::getDefaultCommands(), + [ + new Console\CleanCacheCommand, + new Console\CheckUpdatesCommand, + new Console\RemoveOldFilesCommand, + ] + ); + } + /** * Get the system message queue. * diff --git a/libraries/src/Service/Provider/Application.php b/libraries/src/Service/Provider/Application.php index 2594afa37cba7..3b635b7b3aaab 100644 --- a/libraries/src/Service/Provider/Application.php +++ b/libraries/src/Service/Provider/Application.php @@ -11,9 +11,6 @@ defined('JPATH_PLATFORM') or die; -use Joomla\CMS\Console\CheckUpdatesCommand; -use Joomla\CMS\Console\CleanCacheCommand; -use Joomla\CMS\Console\RemoveOldFilesCommand; use Joomla\Console\Application as BaseConsoleApplication; use Joomla\CMS\Application\AdministratorApplication; use Joomla\CMS\Application\ConsoleApplication; @@ -104,11 +101,6 @@ function (Container $container) $app->setLogger(Log::createDelegatedLogger()); $app->setSession($session); - // Register core commands - $app->addCommand(new CleanCacheCommand); - $app->addCommand(new CheckUpdatesCommand); - $app->addCommand(new RemoveOldFilesCommand); - return $app; }, true