diff --git a/administrator/components/com_content/src/Model/ArticleModel.php b/administrator/components/com_content/src/Model/ArticleModel.php index c4c5e0114ce6f..86580466d53ec 100644 --- a/administrator/components/com_content/src/Model/ArticleModel.php +++ b/administrator/components/com_content/src/Model/ArticleModel.php @@ -11,7 +11,7 @@ namespace Joomla\Component\Content\Administrator\Model; use Joomla\CMS\Date\Date; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Form\Form; @@ -843,7 +843,7 @@ public function featured($pks, $value = 0, $featuredUp = null, $featuredDown = n // Trigger the before change state event. $eventResult = Factory::getApplication()->getDispatcher()->dispatch( $this->event_before_change_featured, - AbstractEvent::create( + EventFactory::create( $this->event_before_change_featured, [ 'eventClass' => FeatureEvent::class, @@ -948,7 +948,7 @@ public function featured($pks, $value = 0, $featuredUp = null, $featuredDown = n // Trigger the change state event. Factory::getApplication()->getDispatcher()->dispatch( $this->event_after_change_featured, - AbstractEvent::create( + EventFactory::create( $this->event_after_change_featured, [ 'eventClass' => FeatureEvent::class, diff --git a/administrator/components/com_scheduler/src/Helper/SchedulerHelper.php b/administrator/components/com_scheduler/src/Helper/SchedulerHelper.php index c3dcd616515d5..ce5269e1c4dbf 100644 --- a/administrator/components/com_scheduler/src/Helper/SchedulerHelper.php +++ b/administrator/components/com_scheduler/src/Helper/SchedulerHelper.php @@ -11,7 +11,7 @@ namespace Joomla\Component\Scheduler\Administrator\Helper; use Joomla\CMS\Application\AdministratorApplication; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Component\Scheduler\Administrator\Task\TaskOptions; @@ -53,7 +53,7 @@ public static function getTaskOptions(): TaskOptions /** @var AdministratorApplication $app */ $app = Factory::getApplication(); $options = new TaskOptions(); - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTaskOptionsList', [ 'subject' => $options, diff --git a/administrator/components/com_scheduler/src/Model/TaskModel.php b/administrator/components/com_scheduler/src/Model/TaskModel.php index 5d89544d83c95..a5e15f4c8aef4 100644 --- a/administrator/components/com_scheduler/src/Model/TaskModel.php +++ b/administrator/components/com_scheduler/src/Model/TaskModel.php @@ -12,7 +12,7 @@ use Joomla\CMS\Application\AdministratorApplication; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Form\Form; use Joomla\CMS\Form\FormFactoryInterface; @@ -698,7 +698,7 @@ public function unlock(array &$pks): bool return true; } - $event = AbstractEvent::create( + $event = EventFactory::create( $this->event_before_unlock, [ 'subject' => $this, @@ -723,7 +723,7 @@ public function unlock(array &$pks): bool } // Trigger the after unlock event - $event = AbstractEvent::create( + $event = EventFactory::create( $this->event_unlock, [ 'subject' => $this, diff --git a/administrator/components/com_scheduler/src/Table/TaskTable.php b/administrator/components/com_scheduler/src/Table/TaskTable.php index 5a778142d7e22..a18ee3a5666eb 100644 --- a/administrator/components/com_scheduler/src/Table/TaskTable.php +++ b/administrator/components/com_scheduler/src/Table/TaskTable.php @@ -10,7 +10,7 @@ namespace Joomla\Component\Scheduler\Administrator\Table; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\AdminModel; @@ -208,7 +208,7 @@ public function bind($src, $ignore = []): bool public function unlock(array $pks = [], ?int $userId = null): bool { // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTaskBeforeUnlock', [ 'subject' => $this, @@ -282,7 +282,7 @@ public function unlock(array $pks = [], ?int $userId = null): bool } // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTaskAfterUnlock', [ 'subject' => $this, diff --git a/administrator/components/com_scheduler/src/Task/Task.php b/administrator/components/com_scheduler/src/Task/Task.php index 931033aea1e11..fd97b36e6e01e 100644 --- a/administrator/components/com_scheduler/src/Task/Task.php +++ b/administrator/components/com_scheduler/src/Task/Task.php @@ -12,7 +12,7 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Log\Log; @@ -211,7 +211,7 @@ public function run(): bool $this->snapshot['netDuration'] = 0; /** @var ExecuteTaskEvent $event */ - $event = AbstractEvent::create( + $event = EventFactory::create( 'onExecuteTask', [ 'eventClass' => ExecuteTaskEvent::class, @@ -466,7 +466,7 @@ protected function dispatchExitEvent(): void $exitCode = $this->snapshot['status'] ?? 'NA'; $eventName = self::EVENTS_MAP[$exitCode] ?? self::EVENTS_MAP['NA']; - $event = AbstractEvent::create( + $event = EventFactory::create( $eventName, [ 'subject' => $this, diff --git a/administrator/modules/mod_sampledata/src/Helper/SampledataHelper.php b/administrator/modules/mod_sampledata/src/Helper/SampledataHelper.php index f4310aa703c3b..b950edf06552d 100644 --- a/administrator/modules/mod_sampledata/src/Helper/SampledataHelper.php +++ b/administrator/modules/mod_sampledata/src/Helper/SampledataHelper.php @@ -10,7 +10,7 @@ namespace Joomla\Module\Sampledata\Administrator\Helper; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Plugin\PluginHelper; @@ -40,7 +40,7 @@ public function getSampledataList() ->getDispatcher() ->dispatch( 'onSampledataGetOverview', - AbstractEvent::create( + EventFactory::create( 'onSampledataGetOverview', [ 'subject' => new \stdClass(), diff --git a/libraries/src/Event/AbstractEvent.php b/libraries/src/Event/AbstractEvent.php index c5d150074e0bc..4aed79c8f4d6a 100644 --- a/libraries/src/Event/AbstractEvent.php +++ b/libraries/src/Event/AbstractEvent.php @@ -25,7 +25,7 @@ * * You can create a new Event with something like this: * - * $event = AbstractEvent::create('onModelBeforeSomething', $myModel, $arguments); + * $event = \Joomla\CMS\Event\EventFactory::create('onModelBeforeSomething', $myModel, $arguments); * * You can access the subject object from your event Listener using $event['subject']. It is up to your listener to * determine whether it should apply its functionality against the subject. @@ -52,7 +52,8 @@ abstract class AbstractEvent extends Event * @return static * * @since 4.0.0 - * @throws \BadMethodCallException If you do not provide a subject argument + * @throws \BadMethodCallException If you do not provide a subject argument + * @deprecated 6.0 Use \Joomla\CMS\Event\EventFactory::create instead */ public static function create(string $eventName, array $arguments = []) { @@ -109,7 +110,7 @@ public static function create(string $eventName, array $arguments = []) */ public function __construct(string $name, array $arguments = []) { - parent::__construct($name, $arguments); + parent::__construct($name); foreach ($arguments as $argumentName => $value) { $this->setArgument($argumentName, $value); diff --git a/libraries/src/Event/AbstractImmutableEvent.php b/libraries/src/Event/AbstractImmutableEvent.php index 2b27101360b9e..5fb6b4e978423 100644 --- a/libraries/src/Event/AbstractImmutableEvent.php +++ b/libraries/src/Event/AbstractImmutableEvent.php @@ -9,12 +9,17 @@ namespace Joomla\CMS\Event; +use Joomla\Event\AbstractEvent; +use BadMethodCallException; + // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * This class implements the immutable base Event object used system-wide to offer orthogonality. + * Note that it's implementation is very similar to \Joomla\Event\EventImmutable but it also contains the same custom + * setter logic for constructors as in \Joomla\CMS\Event\AbstractEvent * * @see \Joomla\CMS\Event\AbstractEvent * @since 4.0.0 @@ -48,7 +53,33 @@ public function __construct(string $name, array $arguments = []) $this->constructed = true; - parent::__construct($name, $arguments); + parent::__construct($name); + + // Same setter logic as in \Joomla\CMS\Event\AbstractEvent::setArgument + foreach ($arguments as $argumentName => $value) { + // Look for the method for the value pre-processing/validation + $ucfirst = ucfirst($name); + $methodName1 = 'onSet' . $ucfirst; + $methodName2 = 'set' . $ucfirst; + + if (method_exists($this, $methodName1)) { + $value = $this->{$methodName1}($value); + } elseif (method_exists($this, $methodName2)) { + @trigger_error( + sprintf( + 'Use method "%s" for value pre-processing is deprecated, and will not work in Joomla 6. Use "%s" instead. Event %s', + $methodName2, + $methodName1, + \get_class($this) + ), + E_USER_DEPRECATED + ); + + $value = $this->{$methodName2}($value); + } + + $this->arguments[$argumentName] = $value; + } } /** @@ -62,11 +93,11 @@ public function __construct(string $name, array $arguments = []) * @since 4.0.0 * @throws \BadMethodCallException */ - public function offsetSet($name, $value) + public function offsetSet($name, mixed $value): void { // B/C check for plugins which use $event['result'] = $result; if ($name === 'result') { - parent::offsetSet($name, $value); + $this->arguments[$name] = $value; @trigger_error( 'Setting a result in an immutable event is deprecated, and will not work in Joomla 6. Event ' . $this->getName(), @@ -95,7 +126,7 @@ public function offsetSet($name, $value) * @since 4.0.0 * @throws \BadMethodCallException */ - public function offsetUnset($name) + public function offsetUnset($name): void { throw new \BadMethodCallException( sprintf( diff --git a/libraries/src/Event/EventFactory.php b/libraries/src/Event/EventFactory.php new file mode 100644 index 0000000000000..2fb0fe87d4130 --- /dev/null +++ b/libraries/src/Event/EventFactory.php @@ -0,0 +1,91 @@ + + * @license GNU General Public License version 2 or later; see LICENSE + */ + +namespace Joomla\CMS\Event; + +use Joomla\Event\Event; +use Joomla\Event\EventInterface; +use Joomla\String\Normalise; + +/** + * This class is a factory system that allows the creation of most core events in the Joomla Ecosystem, falling back to + * the creation of a \Joomla\CMS\Event\GenericEvent object for the class if no specific event class is matched. You can + * create a new Event with something like this: + * + * $event = EventFactory::create('onModelBeforeSomething', $myModel, $arguments); + * + * You can access the subject object from your event Listener using $event['subject']. It is up to your listener to + * determine whether it should apply its functionality against the subject. + * + * @since __DEPLOY_VERSION__ + */ +abstract class EventFactory { + use CoreEventAware; + + /** + * Creates a new CMS event object for a given event name and subject. The following arguments must be given: + * subject object The subject of the event. This is the core object you are going to manipulate. + * eventClass string The Event class name. If you do not provide it Joomla\CMS\Events\ + * will be used. + * + * @param string $eventName The name of the event, e.g. onTableBeforeLoad + * @param array $arguments Additional arguments to pass to the event + * + * @return EventInterface + * + * @since 4.0.0 + * @throws \BadMethodCallException If you do not provide a subject argument + */ + public static function create(string $eventName, array $arguments = []) + { + // Get the class name from the arguments, if specified + $eventClassName = ''; + + if (isset($arguments['eventClass'])) { + $eventClassName = $arguments['eventClass']; + + unset($arguments['eventClass']); + } + + /** + * If the class name isn't set/found determine it from the event name, e.g. TableBeforeLoadEvent from + * the onTableBeforeLoad event name. + */ + if (empty($eventClassName) || !class_exists($eventClassName, true)) { + $bareName = strpos($eventName, 'on') === 0 ? substr($eventName, 2) : $eventName; + $parts = Normalise::fromCamelCase($bareName, true); + $eventClassName = __NAMESPACE__ . '\\' . ucfirst(array_shift($parts)) . '\\'; + $eventClassName .= implode('', $parts); + $eventClassName .= 'Event'; + } + + // Make sure a non-empty subject argument exists and that it is an object + if (!isset($arguments['subject']) || empty($arguments['subject']) || !\is_object($arguments['subject'])) { + throw new \BadMethodCallException("No subject given for the $eventName event"); + } + + // Create and return the event object + if (class_exists($eventClassName, true)) { + return new $eventClassName($eventName, $arguments); + } + + /** + * The detection code above failed. This is to be expected, it was written back when we only + * had the Table events. It does not address most other core events. So, let's use our + * fancier detection instead. + */ + $eventClassName = self::getEventClassByEventName($eventName); + + if (!empty($eventClassName) && ($eventClassName !== Event::class)) { + return new $eventClassName($eventName, $arguments); + } + + return new GenericEvent($eventName, $arguments); + } +} diff --git a/libraries/src/Extension/ExtensionManagerTrait.php b/libraries/src/Extension/ExtensionManagerTrait.php index fe2acdcdd20e0..b1aee750d6640 100644 --- a/libraries/src/Extension/ExtensionManagerTrait.php +++ b/libraries/src/Extension/ExtensionManagerTrait.php @@ -10,7 +10,7 @@ namespace Joomla\CMS\Extension; use Joomla\CMS\Dispatcher\ModuleDispatcherFactory; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Helper\HelperFactory; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Plugin\PluginHelper; @@ -122,7 +122,7 @@ private function loadExtension($type, $extensionName, $extensionPath) $container->get(DispatcherInterface::class)->dispatch( 'onBeforeExtensionBoot', - AbstractEvent::create( + EventFactory::create( 'onBeforeExtensionBoot', [ 'subject' => $this, @@ -163,7 +163,7 @@ private function loadExtension($type, $extensionName, $extensionPath) $container->get(DispatcherInterface::class)->dispatch( 'onAfterExtensionBoot', - AbstractEvent::create( + EventFactory::create( 'onAfterExtensionBoot', [ 'subject' => $this, diff --git a/libraries/src/MVC/Model/AdminModel.php b/libraries/src/MVC/Model/AdminModel.php index a2c92bab8b75c..9b4f9ffce948f 100644 --- a/libraries/src/MVC/Model/AdminModel.php +++ b/libraries/src/MVC/Model/AdminModel.php @@ -10,6 +10,7 @@ namespace Joomla\CMS\MVC\Model; use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Event\Model; use Joomla\CMS\Factory; use Joomla\CMS\Form\FormFactoryInterface; @@ -705,7 +706,7 @@ protected function batchTag($value, $pks, $contexts) $this->table->reset(); $this->table->load($pk); - $setTagsEvent = \Joomla\CMS\Event\AbstractEvent::create( + $setTagsEvent = EventFactory::create( 'onTableSetNewTags', [ 'subject' => $this->table, diff --git a/libraries/src/MVC/View/HtmlView.php b/libraries/src/MVC/View/HtmlView.php index 0c229daab0096..ab3434d96b1c4 100644 --- a/libraries/src/MVC/View/HtmlView.php +++ b/libraries/src/MVC/View/HtmlView.php @@ -10,7 +10,7 @@ namespace Joomla\CMS\MVC\View; use Joomla\CMS\Application\ApplicationHelper; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Event\View\DisplayEvent; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -191,7 +191,7 @@ public function display($tpl = null) $app->getDispatcher()->dispatch( 'onBeforeDisplay', - AbstractEvent::create( + EventFactory::create( 'onBeforeDisplay', [ 'eventClass' => DisplayEvent::class, @@ -205,7 +205,7 @@ public function display($tpl = null) $eventResult = $app->getDispatcher()->dispatch( 'onAfterDisplay', - AbstractEvent::create( + EventFactory::create( 'onAfterDisplay', [ 'eventClass' => DisplayEvent::class, diff --git a/libraries/src/Table/Nested.php b/libraries/src/Table/Nested.php index 6eedf829bec34..5bc9931a72b39 100644 --- a/libraries/src/Table/Nested.php +++ b/libraries/src/Table/Nested.php @@ -10,6 +10,7 @@ namespace Joomla\CMS\Table; use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\Event\Dispatcher; use Joomla\Event\Event; use Joomla\Utilities\ArrayHelper; @@ -698,7 +699,7 @@ public function store($updateNulls = false) $k = $this->_tbl_key; // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeStore', [ 'subject' => $this, @@ -839,7 +840,7 @@ public function store($updateNulls = false) } // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterStore', [ 'subject' => $this, diff --git a/libraries/src/Table/Table.php b/libraries/src/Table/Table.php index a4d3ba45d1265..fffe01e3f4083 100644 --- a/libraries/src/Table/Table.php +++ b/libraries/src/Table/Table.php @@ -10,7 +10,7 @@ namespace Joomla\CMS\Table; use Joomla\CMS\Access\Rules; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Event\Checkin\AfterCheckinEvent as GlobalAfterCheckinEvent; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -222,7 +222,7 @@ public function __construct($table, $key, DatabaseDriver $db, DispatcherInterfac $this->setDispatcher($dispatcher); - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableObjectCreate', [ 'subject' => $this, @@ -593,7 +593,7 @@ public function getRules() */ public function reset() { - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeReset', [ 'subject' => $this, @@ -612,7 +612,7 @@ public function reset() // Reset table errors $this->_errors = []; - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterReset', [ 'subject' => $this, @@ -652,7 +652,7 @@ public function bind($src, $ignore = []) $ignore = explode(' ', $ignore); } - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeBind', [ 'subject' => $this, @@ -686,7 +686,7 @@ public function bind($src, $ignore = []) } } - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterBind', [ 'subject' => $this, @@ -716,7 +716,7 @@ public function bind($src, $ignore = []) public function load($keys = null, $reset = true) { // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeLoad', [ 'subject' => $this, @@ -788,7 +788,7 @@ public function load($keys = null, $reset = true) } // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterLoad', [ 'subject' => $this, @@ -813,7 +813,7 @@ public function load($keys = null, $reset = true) public function check() { // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableCheck', [ 'subject' => $this, @@ -843,7 +843,7 @@ public function store($updateNulls = false) $k = $this->_tbl_keys; // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeStore', [ 'subject' => $this, @@ -946,7 +946,7 @@ public function store($updateNulls = false) } // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterStore', [ 'subject' => $this, @@ -1040,7 +1040,7 @@ public function delete($pk = null) } // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeDelete', [ 'subject' => $this, @@ -1075,7 +1075,7 @@ public function delete($pk = null) $this->_db->execute(); // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterDelete', [ 'subject' => $this, @@ -1105,7 +1105,7 @@ public function delete($pk = null) public function checkOut($userId, $pk = null) { // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeCheckout', [ 'subject' => $this, @@ -1159,7 +1159,7 @@ public function checkOut($userId, $pk = null) $this->$checkedOutTimeField = $time; // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterCheckout', [ 'subject' => $this, @@ -1187,7 +1187,7 @@ public function checkOut($userId, $pk = null) public function checkIn($pk = null) { // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeCheckin', [ 'subject' => $this, @@ -1242,7 +1242,7 @@ public function checkIn($pk = null) $this->$checkedOutTimeField = $this->_supportNullValue ? null : ''; // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterCheckin', [ 'subject' => $this, @@ -1304,7 +1304,7 @@ public function hasPrimaryKey() public function hit($pk = null) { // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeHit', [ 'subject' => $this, @@ -1351,7 +1351,7 @@ public function hit($pk = null) $this->hits++; // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterHit', [ 'subject' => $this, @@ -1513,7 +1513,7 @@ public function reorder($where = '') } // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeReorder', [ 'subject' => $this, @@ -1527,7 +1527,7 @@ public function reorder($where = '') $this->_db->execute(); // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterReorder', [ 'subject' => $this, @@ -1590,7 +1590,7 @@ public function move($delta, $where = '') } // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforeMove', [ 'subject' => $this, @@ -1637,7 +1637,7 @@ public function move($delta, $where = '') } // Post-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterMove', [ 'subject' => $this, @@ -1671,7 +1671,7 @@ public function publish($pks = null, $state = 1, $userId = 0) $state = (int) $state; // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableBeforePublish', [ 'subject' => $this, @@ -1776,7 +1776,7 @@ public function publish($pks = null, $state = 1, $userId = 0) $this->setError(''); // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onTableAfterPublish', [ 'subject' => $this, diff --git a/libraries/src/Versioning/Versioning.php b/libraries/src/Versioning/Versioning.php index c121196bab239..3d2250ff898f5 100644 --- a/libraries/src/Versioning/Versioning.php +++ b/libraries/src/Versioning/Versioning.php @@ -10,7 +10,7 @@ namespace Joomla\CMS\Versioning; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Table\Table; @@ -112,7 +112,7 @@ public static function store($typeAlias, $id, $data, $note = '') PluginHelper::importPlugin('workflow'); // Pre-processing by observers - $event = AbstractEvent::create( + $event = EventFactory::create( 'onContentVersioningPrepareTable', [ 'subject' => $historyTable, diff --git a/libraries/src/WebAsset/WebAssetRegistry.php b/libraries/src/WebAsset/WebAssetRegistry.php index 91d361b930188..8b6446118424e 100644 --- a/libraries/src/WebAsset/WebAssetRegistry.php +++ b/libraries/src/WebAsset/WebAssetRegistry.php @@ -9,7 +9,7 @@ namespace Joomla\CMS\WebAsset; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Event\WebAsset\WebAssetRegistryAssetChanged; use Joomla\CMS\WebAsset\Exception\UnknownAssetException; use Joomla\Event\Dispatcher as EventDispatcher; @@ -440,7 +440,7 @@ protected function parseRegistryFile($path) protected function dispatchAssetChanged(string $type, WebAssetItemInterface $asset, string $change) { // Trigger the event - $event = AbstractEvent::create( + $event = EventFactory::create( 'onWebAssetRegistryChangedAsset' . ucfirst($change), [ 'eventClass' => WebAssetRegistryAssetChanged::class, diff --git a/libraries/src/Workflow/Workflow.php b/libraries/src/Workflow/Workflow.php index ec7dcebd0e396..d317dab98221d 100644 --- a/libraries/src/Workflow/Workflow.php +++ b/libraries/src/Workflow/Workflow.php @@ -10,7 +10,7 @@ namespace Joomla\CMS\Workflow; use Joomla\CMS\Application\CMSApplication; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Event\Workflow\WorkflowTransitionEvent; use Joomla\CMS\Extension\ComponentInterface; use Joomla\CMS\Factory; @@ -379,7 +379,7 @@ public function executeTransition(array $pks, int $transitionId): bool $eventResult = $this->app->getDispatcher()->dispatch( 'onWorkflowBeforeTransition', - AbstractEvent::create( + EventFactory::create( 'onWorkflowBeforeTransition', [ 'eventClass' => 'Joomla\CMS\Event\Workflow\WorkflowTransitionEvent', @@ -401,7 +401,7 @@ public function executeTransition(array $pks, int $transitionId): bool if ($success) { $this->app->getDispatcher()->dispatch( 'onWorkflowAfterTransition', - AbstractEvent::create( + EventFactory::create( 'onWorkflowAfterTransition', [ 'eventClass' => WorkflowTransitionEvent::class, diff --git a/libraries/src/Workflow/WorkflowServiceTrait.php b/libraries/src/Workflow/WorkflowServiceTrait.php index a8e3a662d45b5..f0f69d61094b1 100644 --- a/libraries/src/Workflow/WorkflowServiceTrait.php +++ b/libraries/src/Workflow/WorkflowServiceTrait.php @@ -10,7 +10,7 @@ namespace Joomla\CMS\Workflow; use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\MVC\Model\WorkflowModelInterface; @@ -96,7 +96,7 @@ public function isFunctionalityUsed($functionality, $extension): bool $eventResult = $app->getDispatcher()->dispatch( 'onWorkflowFunctionalityUsed', - AbstractEvent::create( + EventFactory::create( 'onWorkflowFunctionalityUsed', [ 'eventClass' => 'Joomla\CMS\Event\Workflow\WorkflowFunctionalityUsedEvent', diff --git a/plugins/workflow/featuring/src/Extension/Featuring.php b/plugins/workflow/featuring/src/Extension/Featuring.php index 9cf2ead326dbd..700cbac7b21de 100644 --- a/plugins/workflow/featuring/src/Extension/Featuring.php +++ b/plugins/workflow/featuring/src/Extension/Featuring.php @@ -10,7 +10,7 @@ namespace Joomla\Plugin\Workflow\Featuring\Extension; -use Joomla\CMS\Event\AbstractEvent; +use Joomla\CMS\Event\EventFactory; use Joomla\CMS\Event\Model; use Joomla\CMS\Event\Table\BeforeStoreEvent; use Joomla\CMS\Event\View\DisplayEvent; @@ -266,7 +266,7 @@ public function onWorkflowBeforeTransition(WorkflowTransitionEvent $event) // Trigger the change state event. $eventResult = $this->getApplication()->getDispatcher()->dispatch( 'onContentBeforeChangeFeatured', - AbstractEvent::create( + EventFactory::create( 'onContentBeforeChangeFeatured', [ 'eventClass' => 'Joomla\Component\Content\Administrator\Event\Model\FeatureEvent',