Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TraceableEventDispatcher.php

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\Debug

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal