public function handle(Event $event, Response $response) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type')) { return $response; } $request = $this->container->getRequestService(); if ('3' === substr($response->getStatusCode(), 0, 1) || $response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $request->getRequestFormat() || $request->isXmlHttpRequest()) { return $response; } $response->setContent($this->injectToolbar($response)); return $response; }
/** * Persists the Response HTTP headers. * * @param Symfony\Components\HttpKernel\Response $response A Response instance * * @return array An array of HTTP headers */ protected function persistResponse(Response $response) { $headers = $response->headers->all(); $headers['X-Status'] = array($response->getStatusCode()); return $headers; }