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>
23 interface EventDispatcherInterface
26 * Dispatches an event to all registered listeners.
28 * @param string $eventName The name of the event to dispatch. The name of
29 * the event is the name of the method that is
30 * invoked on listeners.
31 * @param Event $event The event to pass to the event handlers/listeners.
32 * If not supplied, an empty Event instance is created.
38 public function dispatch($eventName, Event
$event = null);
41 * Adds an event listener that listens on the specified events.
43 * @param string $eventName The event to listen on
44 * @param callable $listener The listener
45 * @param integer $priority The higher this value, the earlier an event
46 * listener will be triggered in the chain (defaults to 0)
50 public function addListener($eventName, $listener, $priority = 0);
53 * Adds an event subscriber.
55 * The subscriber is asked for all the events he is
56 * interested in and added as a listener for these events.
58 * @param EventSubscriberInterface $subscriber The subscriber.
62 public function addSubscriber(EventSubscriberInterface
$subscriber);
65 * Removes an event listener from the specified events.
67 * @param string|array $eventName The event(s) to remove a listener from
68 * @param callable $listener The listener to remove
70 public function removeListener($eventName, $listener);
73 * Removes an event subscriber.
75 * @param EventSubscriberInterface $subscriber The subscriber
77 public function removeSubscriber(EventSubscriberInterface
$subscriber);
80 * Gets the listeners of a specific event or all listeners.
82 * @param string $eventName The name of the event
84 * @return array The event listeners for the specified event, or all event listeners by event name
86 public function getListeners($eventName = null);
89 * Checks whether an event has any registered listeners.
91 * @param string $eventName The name of the event
93 * @return Boolean true if the specified event has any listeners, false otherwise
95 public function hasListeners($eventName = null);