1 | <?php |
||
7 | final class EventDispatcher implements EventDispatcherInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var EventListener[] |
||
11 | */ |
||
12 | private $listeners = []; |
||
13 | |||
14 | /** |
||
15 | * @param AbstractEvent $event |
||
16 | * @param bool $asynchronous |
||
17 | * |
||
18 | * @return AbstractEvent |
||
19 | */ |
||
20 | public function publish(AbstractEvent $event, $asynchronous = false) |
||
28 | |||
29 | /** |
||
30 | * @param EventSubscriberInterface $subscriber |
||
31 | */ |
||
32 | public function subscribe(EventSubscriberInterface $subscriber) |
||
39 | |||
40 | /** |
||
41 | * @param AbstractEvent $event |
||
42 | * @param bool $asynchronous |
||
43 | * |
||
44 | * @return EventListener[] |
||
45 | */ |
||
46 | public function getListeners(AbstractEvent $event, $asynchronous = false) |
||
64 | |||
65 | /** |
||
66 | * Triggers the listeners of an event. |
||
67 | * |
||
68 | * This method can be overridden to add functionality that is executed |
||
69 | * for each listener. |
||
70 | * |
||
71 | * @param EventListener[] $listeners The event listeners. |
||
72 | * @param string $eventName The name of the event to dispatch. |
||
73 | * @param AbstractEvent $event The event object to pass to the event handlers/listeners. |
||
74 | */ |
||
75 | private function doPublish(array $listeners, $eventName, AbstractEvent $event) |
||
81 | } |
||
82 |