Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\EventDispatcher; Chris@0: Chris@0: /** Chris@0: * The EventDispatcherInterface is the central point of Symfony's event listener system. Chris@0: * Listeners are registered on the manager and events are dispatched through the Chris@0: * manager. Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: interface EventDispatcherInterface Chris@0: { Chris@0: /** Chris@0: * Dispatches an event to all registered listeners. Chris@0: * Chris@17: * @param string $eventName The name of the event to dispatch. The name of Chris@17: * the event is the name of the method that is Chris@17: * invoked on listeners. Chris@17: * @param Event|null $event The event to pass to the event handlers/listeners Chris@17: * If not supplied, an empty Event instance is created Chris@0: * Chris@0: * @return Event Chris@0: */ Chris@0: public function dispatch($eventName, Event $event = null); Chris@0: Chris@0: /** Chris@0: * Adds an event listener that listens on the specified events. Chris@0: * Chris@0: * @param string $eventName The event to listen on Chris@0: * @param callable $listener The listener Chris@0: * @param int $priority The higher this value, the earlier an event Chris@0: * listener will be triggered in the chain (defaults to 0) Chris@0: */ Chris@0: public function addListener($eventName, $listener, $priority = 0); Chris@0: Chris@0: /** Chris@0: * Adds an event subscriber. Chris@0: * Chris@17: * The subscriber is asked for all the events it is Chris@0: * interested in and added as a listener for these events. Chris@0: */ Chris@0: public function addSubscriber(EventSubscriberInterface $subscriber); Chris@0: Chris@0: /** Chris@0: * Removes an event listener from the specified events. Chris@0: * Chris@0: * @param string $eventName The event to remove a listener from Chris@0: * @param callable $listener The listener to remove Chris@0: */ Chris@0: public function removeListener($eventName, $listener); Chris@0: Chris@0: public function removeSubscriber(EventSubscriberInterface $subscriber); Chris@0: Chris@0: /** Chris@0: * Gets the listeners of a specific event or all listeners sorted by descending priority. Chris@0: * Chris@17: * @param string|null $eventName The name of the event Chris@0: * Chris@0: * @return array The event listeners for the specified event, or all event listeners by event name Chris@0: */ Chris@0: public function getListeners($eventName = null); Chris@0: Chris@0: /** Chris@0: * Gets the listener priority for a specific event. Chris@0: * Chris@0: * Returns null if the event or the listener does not exist. Chris@0: * Chris@0: * @param string $eventName The name of the event Chris@0: * @param callable $listener The listener Chris@0: * Chris@0: * @return int|null The event listener priority Chris@0: */ Chris@0: public function getListenerPriority($eventName, $listener); Chris@0: Chris@0: /** Chris@0: * Checks whether an event has any registered listeners. Chris@0: * Chris@17: * @param string|null $eventName The name of the event Chris@0: * Chris@0: * @return bool true if the specified event has any listeners, false otherwise Chris@0: */ Chris@0: public function hasListeners($eventName = null); Chris@0: }