\Symfony\Component\EventDispatcherEventDispatcher

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.

Summary

Methods
Properties
Constants
__construct()
dispatch()
getListeners()
getListenerPriority()
hasListeners()
addListener()
removeListener()
addSubscriber()
removeSubscriber()
No public properties found
No constants found
callListeners()
No protected properties found
N/A
sortListeners()
optimizeListeners()
$listeners
$sorted
$optimized
N/A

Properties

$listeners

$listeners

$sorted

$sorted

$optimized

$optimized

Methods

__construct()

__construct() : mixed

Returns

mixed —

dispatch()

dispatch(object  $event, string  $eventName = null) : object

{@inheritdoc}

Parameters

object $event
string $eventName

Returns

object —

getListeners()

getListeners(string  $eventName = null) : (callable[]|callable)[]

Gets the listeners of a specific event or all listeners sorted by descending priority.

Parameters

string $eventName

Returns

(callable[]|callable)[] —

getListenerPriority()

getListenerPriority(string  $eventName, mixed  $listener) : int|null

Gets the listener priority for a specific event.

Parameters

string $eventName
mixed $listener

Returns

int|null —

hasListeners()

hasListeners(string  $eventName = null) : bool

Checks whether an event has any registered listeners.

Parameters

string $eventName

Returns

bool —

addListener()

addListener(string  $eventName, mixed  $listener, int  $priority) : mixed

Adds an event listener that listens on the specified events.

Parameters

string $eventName
mixed $listener
int $priority

The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)

Returns

mixed —

removeListener()

removeListener(string  $eventName, mixed  $listener) : mixed

Removes an event listener from the specified events.

Parameters

string $eventName
mixed $listener

Returns

mixed —

addSubscriber()

addSubscriber(\Symfony\Component\EventDispatcher\EventSubscriberInterface  $subscriber) : mixed

Adds an event subscriber.

Parameters

\Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber

Returns

mixed —

removeSubscriber()

removeSubscriber(\Symfony\Component\EventDispatcher\EventSubscriberInterface  $subscriber) : mixed

Parameters

\Symfony\Component\EventDispatcher\EventSubscriberInterface $subscriber

Returns

mixed —

callListeners()

callListeners(callable[]  $listeners, string  $eventName, object  $event) : mixed

Triggers the listeners of an event.

This method can be overridden to add functionality that is executed for each listener.

Parameters

callable[] $listeners

The event listeners

string $eventName

The name of the event to dispatch

object $event

The event object to pass to the event handlers/listeners

Returns

mixed —

sortListeners()

sortListeners(string  $eventName) : mixed

Sorts the internal list of listeners for the given event by priority.

Parameters

string $eventName

Returns

mixed —

optimizeListeners()

optimizeListeners(string  $eventName) : array

Optimizes the internal list of listeners for the given event by priority.

Parameters

string $eventName

Returns

array —