public function ContainerAwareTraceableEventDispatcher::dispatch

Lazily loads listeners for this event from the dependency injection container.

Throws

\InvalidArgumentException if the service is not defined

Overrides ContainerAwareEventDispatcher::dispatch

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php, line 56

Class

ContainerAwareTraceableEventDispatcher
Extends the ContainerAwareEventDispatcher to add some debugging tools.

Namespace

Symfony\Component\HttpKernel\Debug

Code

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