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
- addListener() : mixed
- Adds an event listener that listens on the specified events.
- addSubscriber() : mixed
- Adds an event subscriber.
- dispatch() : object
- Provide all relevant listeners with an event to process.
- getListenerPriority() : int|null
- Gets the listener priority for a specific event.
- getListeners() : array<string|int, mixed>
- 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() : mixed
- Removes an event listener from the specified events.
- removeSubscriber() : mixed
Methods
addListener()
Adds an event listener that listens on the specified events.
public
addListener(string $eventName, callable $listener, int $priority) : mixed
Parameters
- $eventName : string
- $listener : callable
-
The listener
- $priority : int
-
The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)
Return values
mixed —addSubscriber()
Adds an event subscriber.
public
addSubscriber(EventSubscriberInterface $subscriber) : mixed
The subscriber is asked for all the events it is interested in and added as a listener for these events.
Parameters
- $subscriber : EventSubscriberInterface
Return values
mixed —dispatch()
Provide all relevant listeners with an event to process.
public
dispatch(object $event) : object
Parameters
- $event : object
-
The object to process.
Return values
object —The Event that was passed, now modified by listeners.
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
-
The listener
Return values
int|null —The event listener priority
getListeners()
Gets the listeners of a specific event or all listeners sorted by descending priority.
public
getListeners([string $eventName = null ]) : array<string|int, mixed>
Parameters
- $eventName : string = null
Return values
array<string|int, mixed> —The event listeners for the specified event, or all event listeners by event name
hasListeners()
Checks whether an event has any registered listeners.
public
hasListeners([string $eventName = null ]) : bool
Parameters
- $eventName : string = null
Return values
bool —true if the specified event has any listeners, false otherwise
removeListener()
Removes an event listener from the specified events.
public
removeListener(string $eventName, callable $listener) : mixed
Parameters
- $eventName : string
- $listener : callable
-
The listener to remove
Return values
mixed —removeSubscriber()
public
removeSubscriber(EventSubscriberInterface $subscriber) : mixed
Parameters
- $subscriber : EventSubscriberInterface