1 | <?php |
||
19 | abstract class EventDispatcherAdapter implements SymfonyDispatcher |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * The Laravel Events Dispatcher |
||
24 | * @var \Illuminate\Contracts\Events\Dispatcher or \Illuminate\Events\Dispatcher |
||
25 | */ |
||
26 | protected $laravelDispatcher; |
||
27 | |||
28 | /** |
||
29 | * The Symfony Event Dispatcher |
||
30 | * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface |
||
31 | */ |
||
32 | protected $symfonyDispatcher; |
||
33 | |||
34 | /** |
||
35 | * Dispatches an event to all registered listeners. |
||
36 | * |
||
37 | * @param string $eventName The name of the event to dispatch. The name of |
||
38 | * the event is the name of the method that is |
||
39 | * invoked on listeners. |
||
40 | * @param Event $event The event to pass to the event handlers/listeners. |
||
41 | * If not supplied, an empty Event instance is created. |
||
42 | * |
||
43 | * @return Event |
||
44 | * |
||
45 | * @api |
||
46 | */ |
||
47 | public function dispatch($eventName, Event $event = null) |
||
52 | |||
53 | /** |
||
54 | * Adds an event listener that listens on the specified events. |
||
55 | * |
||
56 | * @param string $eventName The event to listen on |
||
57 | * @param callable $listener The listener |
||
58 | * @param int $priority The higher this value, the earlier an event |
||
59 | * listener will be triggered in the chain (defaults to 0) |
||
60 | * |
||
61 | * @api |
||
62 | */ |
||
63 | public function addListener($eventName, $listener, $priority = 0) |
||
67 | |||
68 | /** |
||
69 | * Adds an event subscriber. |
||
70 | * |
||
71 | * The subscriber is asked for all the events he is |
||
72 | * interested in and added as a listener for these events. |
||
73 | * |
||
74 | * @param EventSubscriberInterface $subscriber The subscriber. |
||
75 | * |
||
76 | * @api |
||
77 | */ |
||
78 | public function addSubscriber(EventSubscriberInterface $subscriber) |
||
82 | |||
83 | /** |
||
84 | * Removes an event listener from the specified events. |
||
85 | * |
||
86 | * @param string $eventName The event to remove a listener from |
||
87 | * @param callable $listenerToBeRemoved The listener to remove |
||
88 | */ |
||
89 | public function removeListener($eventName, $listenerToBeRemoved) |
||
93 | |||
94 | /** |
||
95 | * Removes an event subscriber. |
||
96 | * |
||
97 | * @param EventSubscriberInterface $subscriber The subscriber |
||
98 | */ |
||
99 | public function removeSubscriber(EventSubscriberInterface $subscriber) |
||
103 | |||
104 | /** |
||
105 | * Gets the listeners of a specific event or all listeners. |
||
106 | * |
||
107 | * @param string $eventName The name of the event |
||
108 | * |
||
109 | * @return array The event listeners for the specified event, or all event listeners by event name |
||
110 | */ |
||
111 | public function getListeners($eventName = null) |
||
115 | |||
116 | /** |
||
117 | * Checks whether an event has any registered listeners. |
||
118 | * |
||
119 | * @param string $eventName The name of the event |
||
120 | * |
||
121 | * @return bool true if the specified event has any listeners, false otherwise |
||
122 | */ |
||
123 | public function hasListeners($eventName = null) |
||
128 | |||
129 | /** |
||
130 | * Gets the listener priority for a specific event. |
||
131 | * |
||
132 | * Returns null if the event or the listener does not exist. |
||
133 | * |
||
134 | * @param string $eventName The name of the event |
||
135 | * @param callable $listener The listener |
||
136 | * |
||
137 | * @return int|null The event listener priority |
||
138 | */ |
||
139 | public function getListenerPriority($eventName, $listener) |
||
143 | } |
||
144 |