Lazily loads listeners for this event from the dependency injection container.
\InvalidArgumentException if the service is not defined
Overrides ContainerAwareEventDispatcher::dispatch
public function dispatch($eventName, Event $event = null) {
switch ($eventName) {
case 'kernel.request':
$this->stopwatch
->openSection();
break;
case 'kernel.view':
case 'kernel.response':
// stop only if a controller has been executed
try {
$this->stopwatch
->stop('controller');
} catch (\LogicException $e) {
}
break;
case 'kernel.terminate':
$token = $event
->getResponse()->headers
->get('X-Debug-Token');
$this->stopwatch
->openSection($token);
break;
}
$e1 = $this->stopwatch
->start($eventName, 'section');
parent::dispatch($eventName, $event);
$e1
->stop();
switch ($eventName) {
case 'kernel.controller':
$this->stopwatch
->start('controller', 'section');
break;
case 'kernel.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 'kernel.terminate':
$this->stopwatch
->stopSection($token);
// 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;
}
return $event;
}