function TraceableEventDispatcher::dispatch
Overrides EventDispatcherInterface::dispatch
File
-
vendor/
symfony/ event-dispatcher/ Debug/ TraceableEventDispatcher.php, line 104
Class
- TraceableEventDispatcher
- Collects some data about event listeners.
Namespace
Symfony\Component\EventDispatcher\DebugCode
public function dispatch(object $event, ?string $eventName = null) : object {
$eventName ??= $event::class;
$this->callStack ??= new \SplObjectStorage();
$currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack
->getCurrentRequest()) ? spl_object_hash($request) : '';
if (null !== $this->logger && $event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
$this->logger
->debug(\sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName));
}
$this->preProcess($eventName);
try {
$this->beforeDispatch($eventName, $event);
try {
$e = $this->stopwatch
->start($eventName, 'section');
try {
$this->dispatcher
->dispatch($event, $eventName);
} finally {
if ($e->isStarted()) {
$e->stop();
}
}
} finally {
$this->afterDispatch($eventName, $event);
}
} finally {
$this->currentRequestHash = $currentRequestHash;
$this->postProcess($eventName);
}
return $event;
}