diff --git a/cli/finder_indexer.php b/cli/finder_indexer.php index f5996464fb6cf..aad0a4959303c 100644 --- a/cli/finder_indexer.php +++ b/cli/finder_indexer.php @@ -78,6 +78,8 @@ */ class FinderCli extends \Joomla\CMS\Application\CliApplication { + use \Joomla\CMS\Application\ExtensionNamespaceMapper; + /** * Start time for the index process * @@ -142,6 +144,8 @@ class FinderCli extends \Joomla\CMS\Application\CliApplication */ protected function doExecute() { + $this->createExtensionNamespaceMap(); + // Print a blank line. $this->out(Text::_('FINDER_CLI')); $this->out('============================'); @@ -325,6 +329,18 @@ private function index() FinderIndexer::resetState(); } + /** + * Gets the name of the current running application. + * + * @return string The name of the application. + * + * @since __DEPLOY_VERSION__ + */ + public function getName() + { + return 'finder-cli'; + } + /** * Purge the index. * @@ -485,7 +501,14 @@ function (\Joomla\DI\Container $container) ); }, true -); +) + ->alias('session.web', 'session.cli') + ->alias('session', 'session.cli') + ->alias('JSession', 'session.cli') + ->alias(\Joomla\CMS\Session\Session::class, 'session.cli') + ->alias(\Joomla\Session\Session::class, 'session.cli') + ->alias(\Joomla\Session\SessionInterface::class, 'session.cli'); + $app = Factory::getContainer()->get('FinderCli'); Factory::$application = $app; $app->execute(); diff --git a/libraries/src/Application/CMSApplicationInterface.php b/libraries/src/Application/CMSApplicationInterface.php index 6b7d0f9442051..c285f78f119e3 100644 --- a/libraries/src/Application/CMSApplicationInterface.php +++ b/libraries/src/Application/CMSApplicationInterface.php @@ -10,6 +10,7 @@ use Joomla\Application\ConfigurationAwareApplicationInterface; use Joomla\CMS\Extension\ExtensionManagerInterface; +use Joomla\CMS\Language\Language; use Joomla\CMS\Menu\AbstractMenu; use Joomla\CMS\User\User; use Joomla\Input\Input; @@ -149,6 +150,15 @@ public function getIdentity(); */ public function getInput(): Input; + /** + * Method to get the application language object. + * + * @return Language The language object + * + * @since __DEPLOY_VERSION__ + */ + public function getLanguage(); + /** * Gets the name of the current running application. * diff --git a/libraries/src/Application/CliApplication.php b/libraries/src/Application/CliApplication.php index 58c6c793b2b74..28a457e5909a4 100644 --- a/libraries/src/Application/CliApplication.php +++ b/libraries/src/Application/CliApplication.php @@ -16,6 +16,8 @@ use Joomla\CMS\Application\CLI\Output\Stdout; use Joomla\CMS\Extension\ExtensionManagerTrait; use Joomla\CMS\Factory; +use Joomla\CMS\Language\Language; +use Joomla\CMS\Language\LanguageFactoryInterface; use Joomla\DI\Container; use Joomla\DI\ContainerAwareTrait; use Joomla\Event\DispatcherAwareInterface; @@ -44,6 +46,14 @@ abstract class CliApplication extends AbstractApplication implements DispatcherA */ protected $output; + /** + * The input. + * + * @var \Joomla\Input\Input + * @since __DEPLOY_VERSION__ + */ + protected $input = null; + /** * CLI Input object * @@ -52,6 +62,22 @@ abstract class CliApplication extends AbstractApplication implements DispatcherA */ protected $cliInput; + /** + * The application language object. + * + * @var Language + * @since __DEPLOY_VERSION__ + */ + protected $language; + + /** + * The application message queue. + * + * @var array + * @since 4.0 + */ + protected $messages = []; + /** * The application instance. * @@ -92,6 +118,8 @@ public function __construct(Input $input = null, Registry $config = null, CliOut $container = $container ?: Factory::getContainer(); $this->setContainer($container); + $this->input = new \Joomla\CMS\Input\Cli; + $this->language = Factory::getLanguage(); $this->output = $output ?: new Stdout; $this->cliInput = $cliInput ?: new CliInput; @@ -100,7 +128,7 @@ public function __construct(Input $input = null, Registry $config = null, CliOut $this->setDispatcher($dispatcher); } - parent::__construct($input ?: new Cli, $config); + parent::__construct($config); // Set the current directory. $this->set('cwd', getcwd()); @@ -109,6 +137,66 @@ public function __construct(Input $input = null, Registry $config = null, CliOut $this->input->set('format', 'cli'); } + /** + * Magic method to access properties of the application. + * + * @param string $name The name of the property. + * + * @return mixed A value if the property name is valid, null otherwise. + * + * @since __DEPLOY_VERSION__ + * @deprecated 3.0 This is a B/C proxy for deprecated read accesses + */ + public function __get($name) + { + switch ($name) + { + case 'input': + @trigger_error( + 'Accessing the input property of the application is deprecated, use the getInput() method instead.', + E_USER_DEPRECATED + ); + + return $this->getInput(); + + default: + $trace = debug_backtrace(); + trigger_error( + sprintf( + 'Undefined property via __get(): %1$s in %2$s on line %3$s', + $name, + $trace[0]['file'], + $trace[0]['line'] + ), + E_USER_NOTICE + ); + } + } + + /** + * Method to get the application input object. + * + * @return Input + * + * @since __DEPLOY_VERSION__ + */ + public function getInput(): Input + { + return $this->input; + } + + /** + * Method to get the application language object. + * + * @return Language The language object + * + * @since __DEPLOY_VERSION__ + */ + public function getLanguage() + { + return $this->language; + } + /** * Returns a reference to the global CliApplication object, only creating it if it doesn't already exist. * @@ -148,7 +236,7 @@ public static function getInstance($name = null) public function execute() { // Trigger the onBeforeExecute event - $this->triggerEevent('onBeforeExecute'); + $this->triggerEvent('onBeforeExecute'); // Perform application routines. $this->doExecute(); diff --git a/libraries/src/Application/ConsoleApplication.php b/libraries/src/Application/ConsoleApplication.php index 53d5a100b87d2..8d0185d6902e2 100644 --- a/libraries/src/Application/ConsoleApplication.php +++ b/libraries/src/Application/ConsoleApplication.php @@ -13,6 +13,7 @@ use Joomla\CMS\Console; use Joomla\CMS\Extension\ExtensionManagerTrait; use Joomla\CMS\Factory; +use Joomla\CMS\Language\Language; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Console\Application; use Joomla\DI\Container; @@ -52,6 +53,14 @@ class ConsoleApplication extends Application implements DispatcherAwareInterface */ protected $name = null; + /** + * The application language object. + * + * @var Language + * @since __DEPLOY_VERSION__ + */ + protected $language; + /** * The application message queue. * @@ -97,7 +106,8 @@ public function __construct( ) { // Set up a Input object for Controllers etc to use - $this->input = new \Joomla\CMS\Input\Cli; + $this->input = new \Joomla\CMS\Input\Cli; + $this->language = Factory::getLanguage(); parent::__construct($input, $output, $config); @@ -300,6 +310,18 @@ public function getInput(): Input return $this->input; } + /** + * Method to get the application language object. + * + * @return Language The language object + * + * @since __DEPLOY_VERSION__ + */ + public function getLanguage() + { + return $this->language; + } + /** * Get the system message queue. *