function TraceableEventDispatcher::postDispatch

Called after dispatching the event.

Parameters

string $eventName The event name:

Event $event The event:

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

File

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

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