TraceableEventDispatcher
in package
implements
EventDispatcherInterface, ResetInterface
Collects some data about event listeners.
This event dispatcher delegates the dispatching to another one.
Tags
Table of Contents
Interfaces
- EventDispatcherInterface
- The EventDispatcherInterface is the central point of Symfony's event listener system.
- ResetInterface
- Provides a way to reset an object to its initial state.
Properties
- $logger : mixed
- $stopwatch : mixed
- $callStack : SplObjectStorage<WrappedListener, array{: string, : string}>|null
- $currentRequestHash : string
- $dispatcher : EventDispatcherInterface
- $orphanedEvents : array<string|int, mixed>
- $requestStack : RequestStack|null
- $wrappedListeners : array<string|int, mixed>
Methods
- __call() : mixed
- Proxies all method calls to the original event dispatcher.
- __construct() : mixed
- addListener() : void
- Adds an event listener that listens on the specified events.
- addSubscriber() : void
- Adds an event subscriber.
- dispatch() : T
- Dispatches an event to all registered listeners.
- getCalledListeners() : array<string|int, mixed>
- getListenerPriority() : int|null
- Gets the listener priority for a specific event.
- getListeners() : array<string|int, array<string|int, callable>|callable>
- Gets the listeners of a specific event or all listeners sorted by descending priority.
- getNotCalledListeners() : array<string|int, mixed>
- getOrphanedEvents() : array<string|int, mixed>
- hasListeners() : bool
- Checks whether an event has any registered listeners.
- removeListener() : void
- Removes an event listener from the specified events.
- removeSubscriber() : void
- reset() : void
- afterDispatch() : void
- Called after dispatching the event.
- beforeDispatch() : void
- Called before dispatching the event.
- getListenersWithoutPriority() : array<string|int, mixed>
- getListenersWithPriority() : array<string|int, mixed>
- postProcess() : void
- preProcess() : void
- sortNotCalledListeners() : int
Properties
$logger
protected
mixed
$logger
$stopwatch
protected
mixed
$stopwatch
$callStack
private
SplObjectStorage<WrappedListener, array{: string, : string}>|null
$callStack
= null
$currentRequestHash
private
string
$currentRequestHash
= ''
$dispatcher
private
EventDispatcherInterface
$dispatcher
$orphanedEvents
private
array<string|int, mixed>
$orphanedEvents
= []
$requestStack
private
RequestStack|null
$requestStack
$wrappedListeners
private
array<string|int, mixed>
$wrappedListeners
= []
Methods
__call()
Proxies all method calls to the original event dispatcher.
public
__call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
-
The method name
- $arguments : array<string|int, mixed>
-
The method arguments
__construct()
public
__construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch[, LoggerInterface|null $logger = null ][, RequestStack|null $requestStack = null ]) : mixed
Parameters
- $dispatcher : EventDispatcherInterface
- $stopwatch : Stopwatch
- $logger : LoggerInterface|null = null
- $requestStack : RequestStack|null = null
addListener()
Adds an event listener that listens on the specified events.
public
addListener(string $eventName, callable|array<string|int, mixed> $listener[, int $priority = 0 ]) : void
Parameters
- $eventName : string
- $listener : callable|array<string|int, mixed>
- $priority : int = 0
-
The higher this value, the earlier an event listener will be triggered in the chain (defaults to 0)
addSubscriber()
Adds an event subscriber.
public
addSubscriber(EventSubscriberInterface $subscriber) : void
Parameters
- $subscriber : EventSubscriberInterface
dispatch()
Dispatches an event to all registered listeners.
public
dispatch(object $event[, string|null $eventName = null ]) : T
Parameters
- $event : object
-
The event to pass to the event handlers/listeners
- $eventName : string|null = null
-
The name of the event to dispatch. If not supplied, the class of $event should be used instead.
Return values
T —The passed $event MUST be returned
getCalledListeners()
public
getCalledListeners([Request|null $request = null ]) : array<string|int, mixed>
Parameters
- $request : Request|null = null
Return values
array<string|int, mixed>getListenerPriority()
Gets the listener priority for a specific event.
public
getListenerPriority(string $eventName, callable|array<string|int, mixed> $listener) : int|null
Returns null if the event or the listener does not exist.
Parameters
- $eventName : string
- $listener : callable|array<string|int, mixed>
Return values
int|nullgetListeners()
Gets the listeners of a specific event or all listeners sorted by descending priority.
public
getListeners([string|null $eventName = null ]) : array<string|int, array<string|int, callable>|callable>
Parameters
- $eventName : string|null = null
Return values
array<string|int, array<string|int, callable>|callable>getNotCalledListeners()
public
getNotCalledListeners([Request|null $request = null ]) : array<string|int, mixed>
Parameters
- $request : Request|null = null
Return values
array<string|int, mixed>getOrphanedEvents()
public
getOrphanedEvents([Request|null $request = null ]) : array<string|int, mixed>
Parameters
- $request : Request|null = null
Return values
array<string|int, mixed>hasListeners()
Checks whether an event has any registered listeners.
public
hasListeners([string|null $eventName = null ]) : bool
Parameters
- $eventName : string|null = null
Return values
boolremoveListener()
Removes an event listener from the specified events.
public
removeListener(string $eventName, callable|array<string|int, mixed> $listener) : void
Parameters
- $eventName : string
- $listener : callable|array<string|int, mixed>
removeSubscriber()
public
removeSubscriber(EventSubscriberInterface $subscriber) : void
Parameters
- $subscriber : EventSubscriberInterface
reset()
public
reset() : void
afterDispatch()
Called after dispatching the event.
protected
afterDispatch(string $eventName, object $event) : void
Parameters
- $eventName : string
- $event : object
beforeDispatch()
Called before dispatching the event.
protected
beforeDispatch(string $eventName, object $event) : void
Parameters
- $eventName : string
- $event : object
getListenersWithoutPriority()
private
getListenersWithoutPriority() : array<string|int, mixed>
Return values
array<string|int, mixed>getListenersWithPriority()
private
getListenersWithPriority() : array<string|int, mixed>
Return values
array<string|int, mixed>postProcess()
private
postProcess(string $eventName) : void
Parameters
- $eventName : string
preProcess()
private
preProcess(string $eventName) : void
Parameters
- $eventName : string
sortNotCalledListeners()
private
sortNotCalledListeners(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>