public function handle(Event $event, Response $response)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getParameter('request_type')) {
         return $response;
     }
     $request = $event->getParameter('request');
     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($request, $response));
     return $response;
 }
Exemple #2
0
 /**
  * Persists the Response HTTP headers.
  *
  * @param Symfony\Components\HttpFoundation\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;
 }