diff --git a/chandler/Eventing/EventDispatcher.php b/chandler/Eventing/EventDispatcher.php index e176997..afb0a1d 100644 --- a/chandler/Eventing/EventDispatcher.php +++ b/chandler/Eventing/EventDispatcher.php @@ -1,33 +1,36 @@ -hooks[] = $hook; - return true; } - + function pushEvent(Events\Event $event): Events\Event { - foreach($hooks as $hook) { - if($event instanceof Events\Cancelable) - if($event->isCancelled()) + foreach ($hooks as $hook) { + if ($event instanceof Events\Cancelable) + if ($event->isCancelled()) break; - $method = "on" . str_replace("Event", "", get_class($event)); - if(!method_exists($hook, $methodName)) continue; - + if (!method_exists($hook, $methodName)) continue; $hook->$method($event); } - return $event; } - + use TSimpleSingleton; }