|
|
|
@ -34,11 +34,7 @@ class EventDispatcher
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$listenerReturnValue = null;
|
|
|
|
$listenerReturnValue = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->hasListeners($event)) {
|
|
|
|
foreach ($this->getListeners($event) as $listener) {
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->listeners[$event] as $listener) {
|
|
|
|
|
|
|
|
$listenerReturnValue = $listener(...$args);
|
|
|
|
$listenerReturnValue = $listener(...$args);
|
|
|
|
|
|
|
|
|
|
|
|
if ($listenerReturnValue === false) {
|
|
|
|
if ($listenerReturnValue === false) {
|
|
|
|
@ -58,13 +54,7 @@ class EventDispatcher
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/** @return callable[] */
|
|
|
|
* Get all listeners registered for a specific event.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param string $event Event name
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return array<int, callable> Array of callbacks registered for the event
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getListeners(string $event): array
|
|
|
|
public function getListeners(string $event): array
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return $this->listeners[$event] ?? [];
|
|
|
|
return $this->listeners[$event] ?? [];
|
|
|
|
|