2011-01-25 13:23:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Symfony\Component\EventDispatcher;
|
|
|
|
|
|
|
|
/**
|
2011-03-17 14:27:42 +00:00
|
|
|
* The EventDispatcherInterface is the central point of Symfony's event listener system.
|
2011-03-13 18:03:18 +00:00
|
|
|
* Listeners are registered on the manager and events are dispatched through the
|
|
|
|
* manager.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
2011-01-25 13:23:23 +00:00
|
|
|
*/
|
|
|
|
interface EventDispatcherInterface
|
|
|
|
{
|
2011-03-17 14:27:42 +00:00
|
|
|
/**
|
|
|
|
* Dispatches an event to all registered listeners.
|
|
|
|
*
|
|
|
|
* @param string $eventName The name of the event to dispatch. The name of
|
|
|
|
* the event is the name of the method that is
|
|
|
|
* invoked on listeners.
|
|
|
|
* @param Event $event The event to pass to the event handlers/listeners.
|
|
|
|
* If not supplied, an empty Event instance is created.
|
|
|
|
*/
|
|
|
|
function dispatch($eventName, Event $event = null);
|
|
|
|
|
2011-01-25 13:23:23 +00:00
|
|
|
/**
|
2011-03-13 18:03:18 +00:00
|
|
|
* Adds an event listener that listens on the specified events.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @param string|array $eventNames The event(s) to listen on.
|
|
|
|
* @param object $listener The listener object.
|
|
|
|
* @param integer $priority The higher this value, the earlier an event
|
|
|
|
* listener will be triggered in the chain.
|
|
|
|
* Defaults to 0.
|
2011-01-25 13:23:23 +00:00
|
|
|
*/
|
2011-03-17 14:27:42 +00:00
|
|
|
function addListener($eventNames, $listener, $priority = 0);
|
2011-01-25 13:23:23 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-13 18:03:18 +00:00
|
|
|
* Adds an event subscriber. The subscriber is asked for all the events he is
|
|
|
|
* interested in and added as a listener for these events.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @param EventSubscriberInterface $subscriber The subscriber.
|
|
|
|
* @param integer $priority The higher this value, the earlier an event
|
|
|
|
* listener will be triggered in the chain.
|
|
|
|
* Defaults to 0.
|
2011-01-25 13:23:23 +00:00
|
|
|
*/
|
2011-03-17 14:27:42 +00:00
|
|
|
function addSubscriber(EventSubscriberInterface $subscriber, $priority = 0);
|
2011-01-25 13:23:23 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-13 18:03:18 +00:00
|
|
|
* Removes an event listener from the specified events.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @param string|array $eventNames The event(s) to remove a listener from.
|
|
|
|
* @param object $listener The listener object to remove.
|
2011-01-25 13:23:23 +00:00
|
|
|
*/
|
2011-03-17 14:27:42 +00:00
|
|
|
function removeListener($eventNames, $listener);
|
2011-01-25 13:23:23 +00:00
|
|
|
|
2011-03-18 08:00:58 +00:00
|
|
|
/**
|
|
|
|
* Removes an event subscriber.
|
|
|
|
*
|
|
|
|
* @param EventSubscriberInterface $subscriber The subscriber.
|
|
|
|
*/
|
|
|
|
function removeSubscriber(EventSubscriberInterface $subscriber);
|
|
|
|
|
2011-01-25 13:23:23 +00:00
|
|
|
/**
|
2011-03-13 18:03:18 +00:00
|
|
|
* Gets the listeners of a specific event or all listeners.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @param string $eventName The name of the event.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @return array The event listeners for the specified event, or all event
|
|
|
|
* listeners by event name.
|
2011-01-25 13:23:23 +00:00
|
|
|
*/
|
2011-03-13 18:03:18 +00:00
|
|
|
function getListeners($eventName = null);
|
2011-01-25 13:23:23 +00:00
|
|
|
|
|
|
|
/**
|
2011-03-13 18:03:18 +00:00
|
|
|
* Checks whether an event has any registered listeners.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @param string $eventName The name of the event.
|
2011-01-25 13:23:23 +00:00
|
|
|
*
|
2011-03-13 18:03:18 +00:00
|
|
|
* @return Boolean TRUE if the specified event has any listeners, FALSE
|
|
|
|
* otherwise.
|
2011-01-25 13:23:23 +00:00
|
|
|
*/
|
2011-03-13 18:03:18 +00:00
|
|
|
function hasListeners($eventName);
|
2011-03-17 14:27:42 +00:00
|
|
|
}
|