diff --git a/libraries/src/Application/CMSApplication.php b/libraries/src/Application/CMSApplication.php index d8a72dafa41e7..f8b8dcbd80d05 100644 --- a/libraries/src/Application/CMSApplication.php +++ b/libraries/src/Application/CMSApplication.php @@ -355,14 +355,10 @@ public function execute() PluginHelper::importPlugin('system'); - // Trigger the onBeforeExecute event. - $this->triggerEvent( + // Trigger the onBeforeExecute event + $this->getDispatcher()->dispatch( 'onBeforeExecute', - [ - 'subject' => $this, - 'eventClass' => BeforeExecuteEvent::class, - 'container' => $this->getContainer() - ] + new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) ); // Mark beforeExecute in the profiler. diff --git a/libraries/src/Application/CliApplication.php b/libraries/src/Application/CliApplication.php index 0b2bd5cfc7246..dbd4ad6d159c3 100644 --- a/libraries/src/Application/CliApplication.php +++ b/libraries/src/Application/CliApplication.php @@ -14,6 +14,7 @@ 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\Input\Cli; use Joomla\Input\Input; @@ -145,8 +146,11 @@ public static function getInstance($name = null) */ public function execute() { - // Trigger the onBeforeExecute event. - $this->triggerEvent('onBeforeExecute'); + // Trigger the onBeforeExecute event + $this->getDispatcher()->dispatch( + 'onBeforeExecute', + new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) + ); // Perform application routines. $this->doExecute(); diff --git a/libraries/src/Application/DaemonApplication.php b/libraries/src/Application/DaemonApplication.php index 4c7deeee117ad..e40b4a7568053 100644 --- a/libraries/src/Application/DaemonApplication.php +++ b/libraries/src/Application/DaemonApplication.php @@ -12,6 +12,7 @@ jimport('joomla.filesystem.folder'); +use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\Event\DispatcherInterface; use Joomla\Registry\Registry; @@ -362,8 +363,11 @@ public function loadConfiguration($data) */ public function execute() { - // Trigger the onBeforeExecute event. - $this->triggerEvent('onBeforeExecute'); + // Trigger the onBeforeExecute event + $this->getDispatcher()->dispatch( + 'onBeforeExecute', + new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) + ); // Enable basic garbage collection. gc_enable(); diff --git a/libraries/src/Application/WebApplication.php b/libraries/src/Application/WebApplication.php index 9dfdccdaa7afc..eb8c8e4a5e0f3 100644 --- a/libraries/src/Application/WebApplication.php +++ b/libraries/src/Application/WebApplication.php @@ -13,6 +13,7 @@ use Joomla\Application\AbstractWebApplication; use Joomla\Application\Web\WebClient; use Joomla\CMS\Document\Document; +use Joomla\CMS\Event\BeforeExecuteEvent; use Joomla\CMS\Input\Input; use Joomla\CMS\Language\Language; use Joomla\CMS\User\User; @@ -128,8 +129,11 @@ public static function getInstance($name = null) */ public function execute() { - // Trigger the onBeforeExecute event. - $this->triggerEvent('onBeforeExecute'); + // Trigger the onBeforeExecute event + $this->getDispatcher()->dispatch( + 'onBeforeExecute', + new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()]) + ); // Perform application routines. $this->doExecute();