Skip to content

Commit 79fd949

Browse files
laoneordeutz
authored andcommitted
Trigger the onBeforeExecute correctly through the dispatcher (#20448)
1 parent 50a5d4c commit 79fd949

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

libraries/src/Application/CMSApplication.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,10 @@ public function execute()
355355

356356
PluginHelper::importPlugin('system');
357357

358-
// Trigger the onBeforeExecute event.
359-
$this->triggerEvent(
358+
// Trigger the onBeforeExecute event
359+
$this->getDispatcher()->dispatch(
360360
'onBeforeExecute',
361-
[
362-
'subject' => $this,
363-
'eventClass' => BeforeExecuteEvent::class,
364-
'container' => $this->getContainer()
365-
]
361+
new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()])
366362
);
367363

368364
// Mark beforeExecute in the profiler.

libraries/src/Application/CliApplication.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Joomla\CMS\Application\CLI\CliInput;
1515
use Joomla\CMS\Application\CLI\CliOutput;
1616
use Joomla\CMS\Application\CLI\Output\Stdout;
17+
use Joomla\CMS\Event\BeforeExecuteEvent;
1718
use Joomla\CMS\Extension\ExtensionManagerTrait;
1819
use Joomla\Input\Cli;
1920
use Joomla\Input\Input;
@@ -145,8 +146,11 @@ public static function getInstance($name = null)
145146
*/
146147
public function execute()
147148
{
148-
// Trigger the onBeforeExecute event.
149-
$this->triggerEvent('onBeforeExecute');
149+
// Trigger the onBeforeExecute event
150+
$this->getDispatcher()->dispatch(
151+
'onBeforeExecute',
152+
new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()])
153+
);
150154

151155
// Perform application routines.
152156
$this->doExecute();

libraries/src/Application/DaemonApplication.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
jimport('joomla.filesystem.folder');
1414

15+
use Joomla\CMS\Event\BeforeExecuteEvent;
1516
use Joomla\Event\DispatcherInterface;
1617
use Joomla\Registry\Registry;
1718

@@ -362,8 +363,11 @@ public function loadConfiguration($data)
362363
*/
363364
public function execute()
364365
{
365-
// Trigger the onBeforeExecute event.
366-
$this->triggerEvent('onBeforeExecute');
366+
// Trigger the onBeforeExecute event
367+
$this->getDispatcher()->dispatch(
368+
'onBeforeExecute',
369+
new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()])
370+
);
367371

368372
// Enable basic garbage collection.
369373
gc_enable();

libraries/src/Application/WebApplication.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Joomla\Application\AbstractWebApplication;
1414
use Joomla\Application\Web\WebClient;
1515
use Joomla\CMS\Document\Document;
16+
use Joomla\CMS\Event\BeforeExecuteEvent;
1617
use Joomla\CMS\Input\Input;
1718
use Joomla\CMS\Language\Language;
1819
use Joomla\CMS\User\User;
@@ -128,8 +129,11 @@ public static function getInstance($name = null)
128129
*/
129130
public function execute()
130131
{
131-
// Trigger the onBeforeExecute event.
132-
$this->triggerEvent('onBeforeExecute');
132+
// Trigger the onBeforeExecute event
133+
$this->getDispatcher()->dispatch(
134+
'onBeforeExecute',
135+
new BeforeExecuteEvent('onBeforeExecute', ['subject' => $this, 'container' => $this->getContainer()])
136+
);
133137

134138
// Perform application routines.
135139
$this->doExecute();

0 commit comments

Comments
 (0)