class EventManager (View source)

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.

Methods

void
dispatchEvent(string $eventName, EventArgs|null $eventArgs = null)

Dispatches an event to all registered listeners.

object[]|object[][]
getListeners(string|null $event = null)

Gets the listeners of a specific event or all listeners.

bool
hasListeners(string $event)

Checks whether an event has any registered listeners.

void
addEventListener(string|string[] $events, object $listener)

Adds an event listener that listens on the specified events.

void
removeEventListener(string|string[] $events, object $listener)

Removes an event listener from the specified events.

void
addEventSubscriber(EventSubscriber $subscriber)

Adds an EventSubscriber. The subscriber is asked for all the events it is interested in and added as a listener for these events.

void
removeEventSubscriber(EventSubscriber $subscriber)

Removes an EventSubscriber. The subscriber is asked for all the events it is interested in and removed as a listener for these events.

Details

void dispatchEvent(string $eventName, EventArgs|null $eventArgs = null)

Dispatches an event to all registered listeners.

Parameters

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.
EventArgs|null $eventArgs The event arguments to pass to the event handlers/listeners. If not supplied, the single empty EventArgs instance is used.

Return Value

void

object[]|object[][] getListeners(string|null $event = null)

Gets the listeners of a specific event or all listeners.

Parameters

string|null $event The name of the event.

Return Value

object[]|object[][] The event listeners for the specified event, or all event listeners.

bool hasListeners(string $event)

Checks whether an event has any registered listeners.

Parameters

string $event

Return Value

bool TRUE if the specified event has any listeners, FALSE otherwise.

void addEventListener(string|string[] $events, object $listener)

Adds an event listener that listens on the specified events.

Parameters

string|string[] $events The event(s) to listen on.
object $listener The listener object.

Return Value

void

void removeEventListener(string|string[] $events, object $listener)

Removes an event listener from the specified events.

Parameters

string|string[] $events
object $listener

Return Value

void

void addEventSubscriber(EventSubscriber $subscriber)

Adds an EventSubscriber. The subscriber is asked for all the events it is interested in and added as a listener for these events.

Parameters

EventSubscriber $subscriber The subscriber.

Return Value

void

void removeEventSubscriber(EventSubscriber $subscriber)

Removes an EventSubscriber. The subscriber is asked for all the events it is interested in and removed as a listener for these events.

Parameters

EventSubscriber $subscriber The subscriber.

Return Value

void