You are here

protected function TraceableEventDispatcher::postDispatch in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/EventDispatcher/TraceableEventDispatcher.php \Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher::postDispatch()
  2. 8 webprofiler/src/EventDispatcher/TraceableEventDispatcher.php \Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher::postDispatch()
  3. 8.2 webprofiler/src/EventDispatcher/TraceableEventDispatcher.php \Drupal\webprofiler\EventDispatcher\TraceableEventDispatcher::postDispatch()

Called after dispatching the event.

Parameters

string $eventName: The event name.

\Symfony\Component\EventDispatcher\Event $event: The event.

1 call to TraceableEventDispatcher::postDispatch()
TraceableEventDispatcher::dispatch in webprofiler/src/EventDispatcher/TraceableEventDispatcher.php

File

webprofiler/src/EventDispatcher/TraceableEventDispatcher.php, line 148

Class

TraceableEventDispatcher
Class TraceableEventDispatcher.

Namespace

Drupal\webprofiler\EventDispatcher

Code

protected function postDispatch($eventName, Event $event) {
  switch ($eventName) {
    case KernelEvents::CONTROLLER:
      $this->stopwatch
        ->start('controller', 'section');
      break;
    case KernelEvents::RESPONSE:
      $token = $event
        ->getResponse()->headers
        ->get('X-Debug-Token');
      try {
        $this->stopwatch
          ->stopSection($token);
      } catch (\LogicException $e) {
      }
      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.
      $token = $event
        ->getResponse()->headers
        ->get('X-Debug-Token');
      try {
        $this->stopwatch
          ->stopSection($token);
      } catch (\LogicException $e) {
      }
      break;
  }
}