Skip to content

Commit

Permalink
Use KernelEvents constants in TraceableEventDispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcd committed Dec 28, 2012
1 parent 8df9b7a commit d5948f1
Showing 1 changed file with 8 additions and 7 deletions.
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Debug;

use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\HttpKernel\Profiler\Profiler;
Expand Down Expand Up @@ -372,18 +373,18 @@ private function preDispatch($eventName, Event $event)
}

switch ($eventName) {
case 'kernel.request':
case KernelEvents::REQUEST:
$this->stopwatch->openSection();
break;
case 'kernel.view':
case 'kernel.response':
case KernelEvents::VIEW:
case KernelEvents::RESPONSE:
// stop only if a controller has been executed
try {
$this->stopwatch->stop('controller');
} catch (\LogicException $e) {
}
break;
case 'kernel.terminate':
case KernelEvents::TERMINATE:
$token = $event->getResponse()->headers->get('X-Debug-Token');
$this->stopwatch->openSection($token);
break;
Expand All @@ -393,10 +394,10 @@ private function preDispatch($eventName, Event $event)
private function postDispatch($eventName, Event $event)
{
switch ($eventName) {
case 'kernel.controller':
case KernelEvents::CONTROLLER:
$this->stopwatch->start('controller', 'section');
break;
case 'kernel.response':
case KernelEvents::RESPONSE:
$token = $event->getResponse()->headers->get('X-Debug-Token');
$this->stopwatch->stopSection($token);
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
Expand All @@ -405,7 +406,7 @@ private function postDispatch($eventName, Event $event)
$this->updateProfiles($token, true);
}
break;
case 'kernel.terminate':
case KernelEvents::TERMINATE:
$token = $event->getResponse()->headers->get('X-Debug-Token');
$this->stopwatch->stopSection($token);
// The children profiles have been updated by the previous 'kernel.response'
Expand Down

0 comments on commit d5948f1

Please sign in to comment.