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

Breadcrumb

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

function TraceableEventDispatcher::afterDispatch

Same name in this branch
  1. 11.1.x vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php \Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher::afterDispatch()

Overrides TraceableEventDispatcher::afterDispatch

File

vendor/symfony/http-kernel/Debug/TraceableEventDispatcher.php, line 58

Class

TraceableEventDispatcher
Collects some data about event listeners.

Namespace

Symfony\Component\HttpKernel\Debug

Code

protected function afterDispatch(string $eventName, object $event) : void {
    switch ($eventName) {
        case KernelEvents::CONTROLLER_ARGUMENTS:
            $this->stopwatch
                ->start('controller', 'section');
            break;
        case KernelEvents::RESPONSE:
            $sectionId = $event->getRequest()->attributes
                ->get('_stopwatch_token');
            if (null === $sectionId) {
                break;
            }
            $this->stopwatch
                ->stopSection($sectionId);
            break;
        case KernelEvents::TERMINATE:
            // In the special case described in the `preDispatch` method above, the `$token` section
            // does not exist, then closing it throws an exception which must be caught.
            $sectionId = $event->getRequest()->attributes
                ->get('_stopwatch_token');
            if (null === $sectionId) {
                break;
            }
            try {
                $this->stopwatch
                    ->stopSection($sectionId);
            } catch (\LogicException) {
            }
            break;
    }
}

API Navigation

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