/** * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event */ public function onKernelResponse(FilterResponseEvent $event) { if ($this->profiler->isEnabled()) { $this->xhprofRunId = $this->profiler->createRunId(); // Don't print the link to xhprof run page if // Webprofiler module is enabled, a widget will // be rendered into Webprofiler toolbar. if (!$this->moduleHandler->moduleExists('webprofiler')) { $response = $event->getResponse(); // Try not to break non html pages. $formats = array('xml', 'javascript', 'json', 'plain', 'image', 'application', 'csv', 'x-comma-separated-values'); foreach ($formats as $format) { if ($response->headers->get($format)) { return; } } if ($this->currentUser->hasPermission('access xhprof data')) { $this->injectLink($response, $this->xhprofRunId); } } } }