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

boolean
dispatchEvent(string $eventName, EventArgs $eventArgs = null)

Dispatches an event to all registered listeners.

array
getListeners(string $event = null)

Gets the listeners of a specific event or all listeners.

boolean
hasListeners(string $event)

Checks whether an event has any registered listeners.

addEventListener(string|array $events, object $listener)

Adds an event listener that listens on the specified events.

removeEventListener(string|array $events, object $listener)

Removes an event listener from the specified events.

addEventSubscriber(EventSubscriber $subscriber)

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

Details

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

Return Value

boolean

array getListeners(string $event = null)

Gets the listeners of a specific event or all listeners.

Parameters

string $event The name of the event.

Return Value

array The event listeners for the specified event, or all event listeners.

boolean hasListeners(string $event)

Checks whether an event has any registered listeners.

Parameters

string $event

Return Value

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

addEventListener(string|array $events, object $listener)

Adds an event listener that listens on the specified events.

Parameters

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

removeEventListener(string|array $events, object $listener)

Removes an event listener from the specified events.

Parameters

string|array $events
object $listener

addEventSubscriber(EventSubscriber $subscriber)

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

Parameters

EventSubscriber $subscriber The subscriber.