}
}
- // execute actions
- foreach ($this->inheritedActionsObjects[$name] as $actionObj) {
- if ($actionObj instanceof IParameterizedEventListener) {
- $actionObj->execute($eventObj, $className, $eventName, $parameters);
-
- if (!\is_array($parameters)) {
- throw new SystemException("'" . \get_class($actionObj) . "' breaks the '\$parameters' array!");
- }
- } elseif ($actionObj instanceof ILegacyEventListener) {
- $actionObj->execute($eventObj, $className, $eventName);
- }
- }
+ $this->executeListeners(
+ $this->inheritedActionsObjects[$name],
+ $eventObj,
+ $className,
+ $eventName,
+ $parameters
+ );
}
/**
return $object;
}
+ /**
+ * @param EventListener[] $eventListeners
+ * @since 5.5
+ */
+ protected function executeListeners(
+ array $eventListeners,
+ $eventObj,
+ string $className,
+ string $eventName,
+ array &$parameters
+ ): void {
+ foreach ($eventListeners as $actionObj) {
+ if ($actionObj instanceof IParameterizedEventListener) {
+ $actionObj->execute($eventObj, $className, $eventName, $parameters);
+
+ if (!\is_array($parameters)) {
+ throw new SystemException("'" . \get_class($actionObj) . "' breaks the '\$parameters' array!");
+ }
+ } elseif ($actionObj instanceof ILegacyEventListener) {
+ $actionObj->execute($eventObj, $className, $eventName);
+ }
+ }
+ }
+
/**
* Executes all registered listeners for the given event.
*
}
}
- // execute actions
- foreach ($this->actionsObjects[$name] as $actionObj) {
- if ($actionObj instanceof IParameterizedEventListener) {
- $actionObj->execute($eventObj, $className, $eventName, $parameters);
-
- if (!\is_array($parameters)) {
- throw new SystemException("'" . \get_class($actionObj) . "' breaks the '\$parameters' array!");
- }
- } elseif ($actionObj instanceof ILegacyEventListener) {
- $actionObj->execute($eventObj, $className, $eventName);
- }
- }
+ $this->executeListeners(
+ $this->actionsObjects[$name],
+ $eventObj,
+ $className,
+ $eventName,
+ $parameters
+ );
}
/**