protected function afterDispatch(string
$eventName, object
$event): void
{ switch ($eventName) { case KernelEvents::CONTROLLER_ARGUMENTS:
$this->stopwatch->
start('controller', 'section'
);
break;
case KernelEvents::RESPONSE:
$sectionId =
$event->
getRequest()->attributes->
get('_stopwatch_token'
);
if (null ===
$sectionId) { break;
} $this->stopwatch->
stopSection($sectionId);
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.
$sectionId =
$event->
getRequest()->attributes->
get('_stopwatch_token'
);
if (null ===
$sectionId) { break;
} try { $this->stopwatch->
stopSection($sectionId);
} catch (\LogicException
) { }