EventManager
in package
The EventManager is the central point of Doctrine's event listener system.
Listeners are registered on the manager and events are dispatched through the manager.
Tags
Table of Contents
- $_listeners : array<string|int, mixed>
- Map of registered listeners.
- addEventListener() : void
- Adds an event listener that listens on the specified events.
- addEventSubscriber() : void
- Adds an EventSubscriber. The subscriber is asked for all the events it is interested in and added as a listener for these events.
- dispatchEvent() : bool
- Dispatches an event to all registered listeners.
- getListeners() : array<string|int, mixed>
- Gets the listeners of a specific event or all listeners.
- hasListeners() : bool
- Checks whether an event has any registered listeners.
- removeEventListener() : void
- Removes an event listener from the specified events.
- removeEventSubscriber() : void
- Removes an EventSubscriber. The subscriber is asked for all the events it is interested in and removed as a listener for these events.
Properties
$_listeners
Map of registered listeners.
private
array<string|int, mixed>
$_listeners
= []
Methods
addEventListener()
Adds an event listener that listens on the specified events.
public
addEventListener(string|array<string|int, mixed> $events, object $listener) : void
Parameters
- $events : string|array<string|int, mixed>
-
The event(s) to listen on.
- $listener : object
-
The listener object.
Return values
void —addEventSubscriber()
Adds an EventSubscriber. The subscriber is asked for all the events it is interested in and added as a listener for these events.
public
addEventSubscriber(EventSubscriber $subscriber) : void
Parameters
- $subscriber : EventSubscriber
-
The subscriber.
Return values
void —dispatchEvent()
Dispatches an event to all registered listeners.
public
dispatchEvent(string $eventName[, EventArgs|null $eventArgs = null ]) : bool
Parameters
- $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.
- $eventArgs : EventArgs|null = null
-
The event arguments to pass to the event handlers/listeners. If not supplied, the single empty EventArgs instance is used.
Return values
bool —getListeners()
Gets the listeners of a specific event or all listeners.
public
getListeners([string|null $event = null ]) : array<string|int, mixed>
Parameters
- $event : string|null = null
-
The name of the event.
Return values
array<string|int, mixed> —The event listeners for the specified event, or all event listeners.
hasListeners()
Checks whether an event has any registered listeners.
public
hasListeners(string $event) : bool
Parameters
- $event : string
Return values
bool —TRUE if the specified event has any listeners, FALSE otherwise.
removeEventListener()
Removes an event listener from the specified events.
public
removeEventListener(string|array<string|int, mixed> $events, object $listener) : void
Parameters
- $events : string|array<string|int, mixed>
- $listener : object
Return values
void —removeEventSubscriber()
Removes an EventSubscriber. The subscriber is asked for all the events it is interested in and removed as a listener for these events.
public
removeEventSubscriber(EventSubscriber $subscriber) : void
Parameters
- $subscriber : EventSubscriber
-
The subscriber.