Interface Symfony\Component\EventDispatcher\EventDispatcherInterface

Implemented bySymfony\Component\EventDispatcher\ContainerAwareEventDispatcher, Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface, Symfony\Component\EventDispatcher\EventDispatcher, Symfony\Component\EventDispatcher\ImmutableEventDispatcher

The EventDispatcherInterface is the central point of Symfony's event listener system.

Listeners are registered on the manager and events are dispatched through the manager.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addListener() Adds an event listener that listens on the specified events. Symfony\Component\EventDispatcher\EventDispatcherInterface
addSubscriber() Adds an event subscriber. Symfony\Component\EventDispatcher\EventDispatcherInterface
dispatch() Dispatches an event to all registered listeners. Symfony\Component\EventDispatcher\EventDispatcherInterface
getListeners() Gets the listeners of a specific event or all listeners sorted by descending priority. Symfony\Component\EventDispatcher\EventDispatcherInterface
hasListeners() Checks whether an event has any registered listeners. Symfony\Component\EventDispatcher\EventDispatcherInterface
removeListener() Removes an event listener from the specified events. Symfony\Component\EventDispatcher\EventDispatcherInterface
removeSubscriber() Removes an event subscriber. Symfony\Component\EventDispatcher\EventDispatcherInterface

Method Details

addListener() public abstract method

Adds an event listener that listens on the specified events.

public abstract void addListener ( $eventName, $listener, $priority 0 )
$eventName string

The event to listen on

$listener callable

The listener

$priority int

The higher this value, the earlier an event

                       listener will be triggered in the chain (defaults to 0)
addSubscriber() public abstract method

Adds an event subscriber.

The subscriber is asked for all the events he is interested in and added as a listener for these events.

public abstract void addSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber )
$subscriber Symfony\Component\EventDispatcher\EventSubscriberInterface

The subscriber

dispatch() public abstract method

Dispatches an event to all registered listeners.

public abstract Symfony\Component\EventDispatcher\Event dispatch ( $eventName, Symfony\Component\EventDispatcher\Event $event null )
$eventName string

The name of the event to dispatch. The name of

                     the event is the name of the method that is
                     invoked on listeners.
$event Symfony\Component\EventDispatcher\Event

The event to pass to the event handlers/listeners

                     If not supplied, an empty Event instance is created.
getListeners() public abstract method

Gets the listeners of a specific event or all listeners sorted by descending priority.

public abstract array getListeners ( $eventName null )
$eventName string

The name of the event

return array

The event listeners for the specified event, or all event listeners by event name

hasListeners() public abstract method

Checks whether an event has any registered listeners.

public abstract bool hasListeners ( $eventName null )
$eventName string

The name of the event

return bool

True if the specified event has any listeners, false otherwise

removeListener() public abstract method

Removes an event listener from the specified events.

public abstract void removeListener ( $eventName, $listener )
$eventName string

The event to remove a listener from

$listener callable

The listener to remove

removeSubscriber() public abstract method

Removes an event subscriber.

public abstract void removeSubscriber ( Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber )
$subscriber Symfony\Component\EventDispatcher\EventSubscriberInterface

The subscriber