private 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');
$this->stopwatch
->stopSection($token);
if (HttpKernelInterface::MASTER_REQUEST === $event
->getRequestType()) {
// The profiles can only be updated once they have been created
// that is after the 'kernel.response' event of the main request
$this
->updateProfiles($token, true);
}
break;
case KernelEvents::TERMINATE:
$token = $event
->getResponse()->headers
->get('X-Debug-Token');
// 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.
try {
$this->stopwatch
->stopSection($token);
} catch (\LogicException $e) {
}
// The children profiles have been updated by the previous 'kernel.response'
// event. Only the root profile need to be updated with the 'kernel.terminate'
// timing informations.
$this
->updateProfiles($token, false);
break;
}
foreach ($this->wrappedListeners[$this->id] as $wrapped) {
$this->dispatcher
->removeListener($eventName, $wrapped);
$this->dispatcher
->addListener($eventName, $this->wrappedListeners[$this->id][$wrapped]);
}
unset($this->wrappedListeners[$this->id]);
}