4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\EventDispatcher
;
15 * The EventDispatcherInterface is the central point of Symfony's event listener system.
16 * Listeners are registered on the manager and events are dispatched through the
19 * @author Bernhard Schussek <bschussek@gmail.com>
21 interface EventDispatcherInterface
24 * Dispatches an event to all registered listeners.
26 * @param string $eventName The name of the event to dispatch. The name of
27 * the event is the name of the method that is
28 * invoked on listeners.
29 * @param Event $event The event to pass to the event handlers/listeners.
30 * If not supplied, an empty Event instance is created.
34 public function dispatch($eventName, Event
$event = null);
37 * Adds an event listener that listens on the specified events.
39 * @param string $eventName The event to listen on
40 * @param callable $listener The listener
41 * @param int $priority The higher this value, the earlier an event
42 * listener will be triggered in the chain (defaults to 0)
44 public function addListener($eventName, $listener, $priority = 0);
47 * Adds an event subscriber.
49 * The subscriber is asked for all the events he is
50 * interested in and added as a listener for these events.
52 * @param EventSubscriberInterface $subscriber The subscriber.
54 public function addSubscriber(EventSubscriberInterface
$subscriber);
57 * Removes an event listener from the specified events.
59 * @param string $eventName The event to remove a listener from
60 * @param callable $listener The listener to remove
62 public function removeListener($eventName, $listener);
65 * Removes an event subscriber.
67 * @param EventSubscriberInterface $subscriber The subscriber
69 public function removeSubscriber(EventSubscriberInterface
$subscriber);
72 * Gets the listeners of a specific event or all listeners sorted by descending priority.
74 * @param string $eventName The name of the event
76 * @return array The event listeners for the specified event, or all event listeners by event name
78 public function getListeners($eventName = null);
81 * Checks whether an event has any registered listeners.
83 * @param string $eventName The name of the event
85 * @return bool true if the specified event has any listeners, false otherwise
87 public function hasListeners($eventName = null);