23 private $listeners = [];
29 if (!isset($this->listeners[$eventName])) {
30 $this->listeners[$eventName] = [];
32 $this->listeners[$eventName][] = $callback;
39 if (isset($this->listeners[$eventName])) {
41 for ($i=0, $count=
sizeof($this->listeners[$eventName]); $i<$count; $i++) {
42 $curCallback = $this->listeners[$eventName][$i];
43 if ($curCallback != $callback) {
44 $listeners[] = $curCallback;
47 $this->listeners[$eventName] = $listeners;
55 if (isset($this->listeners[$eventName])) {
56 for ($i=0, $count=
sizeof($this->listeners[$eventName]); $i<$count; $i++) {
57 $curCallback = $this->listeners[$eventName][$i];
58 call_user_func($curCallback, $event);
isStopped()
Check if the event is stopped.
dispatch($eventName, Event $event)
EventManager is responsible for dispatching events to registered listeners.
Event is the base class for all events.
removeListener($eventName, $callback)
addListener($eventName, $callback)
DefaultEventManager is a simple EventManager implementation.