From c89cd500a10ea8050bcd6e739abf039e16113121 Mon Sep 17 00:00:00 2001 From: Ilya Bakhlin Date: Tue, 28 Dec 2021 19:50:49 +0100 Subject: [PATCH] Reformatting the EventDispatcher class. --- chandler/Eventing/EventDispatcher.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) 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; }