EventDispatcherInterface
extends
EventDispatcherInterface
in
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.
Tags
Table of Contents
Methods
- addListener() : void
- Adds an event listener that listens on the specified events.
- addSubscriber() : void
- Adds an event subscriber.
- dispatch() : T
- Dispatches an event to all registered listeners.
- getListenerPriority() : int|null
- Gets the listener priority for a specific event.
- getListeners() : array<string|int, array<string|int, callable>|callable>
- Gets the listeners of a specific event or all listeners sorted by descending priority.
- hasListeners() : bool
- Checks whether an event has any registered listeners.
- removeListener() : void
- Removes an event listener from the specified events.
- removeSubscriber() : void
Methods
addListener()
Adds an event listener that listens on the specified events.
public
addListener(string $eventName, callable $listener[, int $priority = 0 ]) : void
Parameters
- $eventName : string
- $listener : callable
- $priority : int = 0
-
The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)
addSubscriber()
Adds an event subscriber.
public
addSubscriber(EventSubscriberInterface $subscriber) : void
The subscriber is asked for all the events it is interested in and added as a listener for these events.
Parameters
- $subscriber : EventSubscriberInterface
dispatch()
Dispatches an event to all registered listeners.
public
dispatch(T $event[, string|null $eventName = null ]) : T
Parameters
- $event : T
-
The event to pass to the event handlers/listeners
- $eventName : string|null = null
-
The name of the event to dispatch. If not supplied, the class of $event should be used instead.
Tags
Return values
T —The passed $event MUST be returned
getListenerPriority()
Gets the listener priority for a specific event.
public
getListenerPriority(string $eventName, callable $listener) : int|null
Returns null if the event or the listener does not exist.
Parameters
- $eventName : string
- $listener : callable
Return values
int|nullgetListeners()
Gets the listeners of a specific event or all listeners sorted by descending priority.
public
getListeners([string|null $eventName = null ]) : array<string|int, array<string|int, callable>|callable>
Parameters
- $eventName : string|null = null
Return values
array<string|int, array<string|int, callable>|callable>hasListeners()
Checks whether an event has any registered listeners.
public
hasListeners([string|null $eventName = null ]) : bool
Parameters
- $eventName : string|null = null
Return values
boolremoveListener()
Removes an event listener from the specified events.
public
removeListener(string $eventName, callable $listener) : void
Parameters
- $eventName : string
- $listener : callable
removeSubscriber()
public
removeSubscriber(EventSubscriberInterface $subscriber) : void
Parameters
- $subscriber : EventSubscriberInterface