diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index 3d874b8658a7..c27b4c07ae4f 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -14,7 +14,6 @@ use Joomla\CMS\Authentication\Authentication; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Event\AbstractEvent; -use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\CMS\Event\ErrorEvent; use Joomla\CMS\Exception\ExceptionHandler; use Joomla\CMS\Extension\ExtensionManagerTrait; @@ -227,17 +226,6 @@ public function execute() { $this->createExtensionNamespaceMap(); - PluginHelper::importPlugin('system'); - - // Trigger the onBeforeExecute event - $this->getDispatcher()->dispatch( - 'onBeforeExecute', - new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) - ); - - // Mark beforeExecute in the profiler. - JDEBUG ? $this->profiler->mark('beforeExecute event dispatched') : null; - // Perform application routines. $this->doExecute(); diff --git a/libraries/src/Application/CliApplication.php b/libraries/src/Application/CliApplication.php index 1a1bde534793..ea338779cc0e 100644 --- a/libraries/src/Application/CliApplication.php +++ b/libraries/src/Application/CliApplication.php @@ -14,7 +14,6 @@ use Joomla\CMS\Application\CLI\CliInput; use Joomla\CMS\Application\CLI\CliOutput; use Joomla\CMS\Application\CLI\Output\Stdout; -use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\CMS\Extension\ExtensionManagerTrait; use Joomla\CMS\Factory; use Joomla\DI\Container; @@ -149,10 +148,7 @@ public static function getInstance($name = null) public function execute() { // Trigger the onBeforeExecute event - $this->getDispatcher()->dispatch( - 'onBeforeExecute', - new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) - ); + $this->triggerEevent('onBeforeExecute'); // Perform application routines. $this->doExecute(); diff --git a/libraries/src/Application/DaemonApplication.php b/libraries/src/Application/DaemonApplication.php index 5498a1e58e4b..6677084a9423 100644 --- a/libraries/src/Application/DaemonApplication.php +++ b/libraries/src/Application/DaemonApplication.php @@ -10,7 +10,6 @@ \defined('JPATH_PLATFORM') or die; -use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Input\Cli; use Joomla\CMS\Log\Log; @@ -365,10 +364,7 @@ public function loadConfiguration($data) public function execute() { // Trigger the onBeforeExecute event - $this->getDispatcher()->dispatch( - 'onBeforeExecute', - new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) - ); + $this->triggerEvent('onBeforeExecute'); // Enable basic garbage collection. gc_enable(); diff --git a/libraries/src/Application/SiteApplication.php b/libraries/src/Application/SiteApplication.php index 7592291b98e9..e787a8b95e93 100644 --- a/libraries/src/Application/SiteApplication.php +++ b/libraries/src/Application/SiteApplication.php @@ -587,6 +587,13 @@ protected function initialiseApp($options = array()) $user->groups = array($guestUsergroup); } + if ($plugin = PluginHelper::getPlugin('system', 'languagefilter')) + { + $pluginParams = new Registry($plugin->params); + $this->setLanguageFilter(true); + $this->setDetectBrowser($pluginParams->get('detect_browser', 1) == 1); + } + if (empty($options['language'])) { // Detect the specified language diff --git a/libraries/src/Application/WebApplication.php b/libraries/src/Application/WebApplication.php index d63a0a2f3eec..71bac5d60a90 100644 --- a/libraries/src/Application/WebApplication.php +++ b/libraries/src/Application/WebApplication.php @@ -13,7 +13,6 @@ use Joomla\Application\AbstractWebApplication; use Joomla\Application\Web\WebClient; use Joomla\CMS\Document\Document; -use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\CMS\Factory; use Joomla\CMS\Input\Input; use Joomla\CMS\Language\Language; @@ -132,11 +131,8 @@ public static function getInstance($name = null) */ public function execute() { - // Trigger the onBeforeExecute event - $this->getDispatcher()->dispatch( - 'onBeforeExecute', - new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) - ); + // Trigger the onBeforeExecute event. + $this->triggerEvent('onBeforeExecute'); // Perform application routines. $this->doExecute(); diff --git a/libraries/src/Event/BeforeExecuteEvent.php b/libraries/src/Event/BeforeExecuteEvent.php deleted file mode 100644 index 3b3ed9ab92b4..000000000000 --- a/libraries/src/Event/BeforeExecuteEvent.php +++ /dev/null @@ -1,46 +0,0 @@ -getArgument('subject'); - } - - /** - * Get the event's container object - * - * @return Container - * - * @since 4.0.0 - */ - public function getContainer(): Container - { - return $this->arguments['container']; - } -} diff --git a/plugins/system/languagefilter/languagefilter.php b/plugins/system/languagefilter/languagefilter.php index 6338c00b845f..d920128bbd62 100644 --- a/plugins/system/languagefilter/languagefilter.php +++ b/plugins/system/languagefilter/languagefilter.php @@ -14,7 +14,6 @@ use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Association\AssociationServiceInterface; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Language\Associations; @@ -191,30 +190,6 @@ public function onAfterRoute() } } - /** - * Listener for the onBeforeExecute event - * - * @param BeforeExecuteEvent $event The Event object - * - * @return void - * - * @since 4.0 - */ - public function onBeforeExecute(BeforeExecuteEvent $event) - { - /** @var \Joomla\CMS\Application\SiteApplication $app */ - $app = $event->getApplication(); - - if (!$app->isClient('site')) - { - return; - } - - // If a language was specified it has priority, otherwise use user or default language settings - $app->setLanguageFilter(true); - $app->setDetectBrowser($this->params->get('detect_browser', '1') == '1'); - } - /** * Add build preprocess rule to router. *