Documentation

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.

Table of Contents

Properties

$listeners  : array<string, array<string|int, object>>
Map of registered listeners.

Methods

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()  : void
Dispatches an event to all registered listeners.
getAllListeners()  : array<string, array<string|int, object>>
Gets all listeners keyed by event name.
getListeners()  : array<string|int, object>|array<string, array<string|int, object>>
Gets the listeners of a specific event.
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, array<string|int, object>> $listeners = []

=>

Methods

addEventListener()

Adds an event listener that listens on the specified events.

public addEventListener(string|array<string|int, string> $events, object $listener) : void
Parameters
$events : string|array<string|int, string>

The event(s) to listen on.

$listener : object

The listener object.

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.

dispatchEvent()

Dispatches an event to all registered listeners.

public dispatchEvent(string $eventName[, EventArgs|null $eventArgs = null ]) : void
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.

getAllListeners()

Gets all listeners keyed by event name.

public getAllListeners() : array<string, array<string|int, object>>
Return values
array<string, array<string|int, object>>

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

getListeners()

Gets the listeners of a specific event.

public getListeners([string|null $event = null ]) : array<string|int, object>|array<string, array<string|int, object>>
Parameters
$event : string|null = null

The name of the event.

Tags
psalm-return

($event is null ? array<string, object[]> : object[])

Return values
array<string|int, object>|array<string, array<string|int, object>>

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, string> $events, object $listener) : void
Parameters
$events : string|array<string|int, string>
$listener : object

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.


        
On this page

Search results