Helthe\Component\Turbolinks\Turbolinks::decorateResponse PHP Method

decorateResponse() public method

Modifies the HTTP headers and status code of the Response so that it can be properly handled by the Turbolinks javascript.
public decorateResponse ( Request $request, Response $response )
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response
    public function decorateResponse(Request $request, Response $response)
    {
        $this->addRequestMethodCookie($request, $response);
        $this->modifyStatusCode($request, $response);
        if (!$this->canHandleRedirect($request)) {
            return;
        }
        $session = $request->getSession();
        if ($session->has(self::REDIRECT_SESSION_ATTR_NAME)) {
            $response->headers->add(array(self::REDIRECT_RESPONSE_HEADER => $session->remove(self::REDIRECT_SESSION_ATTR_NAME)));
        }
        if ($response->isRedirect() && $response->headers->has('Location')) {
            $session->set(self::REDIRECT_SESSION_ATTR_NAME, $response->headers->get('Location'));
        }
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Filters the Response.
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $this->turbolinks->decorateResponse($event->getRequest(), $event->getResponse());
 }
All Usage Examples Of Helthe\Component\Turbolinks\Turbolinks::decorateResponse