You are browsing the documentation for Symfony 2.4 which is not maintained anymore.
Consider upgrading your projects to Symfony 5.2.
The Traceable Event Dispatcher
The Traceable Event Dispatcher¶
is an event dispatcher that wraps any other event dispatcher and can then
be used to determine which event listeners have been called by the dispatcher.
Pass the event dispatcher to be wrapped and an instance of the
Symfony\Component\Stopwatch\Stopwatch to its constructor:
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; use Symfony\Component\Stopwatch\Stopwatch; // the event dispatcher to debug $eventDispatcher = ...; $traceableEventDispatcher = new TraceableEventDispatcher($eventDispatcher, new Stopwatch());
TraceableEventDispatcher can be used like any other event dispatcher
to register event listeners and dispatch events:
// ... // register an event listener $eventListener = ...; $priority = ...; $traceableEventDispatcher->addListener('the-event-name', $eventListener, $priority); // dispatch an event $event = ...; $traceableEventDispatcher->dispatch('the-event-name', $event);
After your application has been processed, you can use the
method to retrieve an array of event listeners that have been called in your
application. Similarly, the
method returns an array of event listeners that have not been called:
// ... $calledListeners = $traceableEventDispatcher->getCalledListeners(); $notCalledListeners = $traceableEventDispatcher->getNotCalledListeners();
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.