/**
  * @param FilterResponseEvent $event
  *
  * @return Response
  */
 public function pjaxRedirect(FilterResponseEvent $event)
 {
     $request = $event->getRequest();
     $response = $event->getResponse();
     if ($this->pjax->isPjaxRequest($request) && $response->isRedirect()) {
         $redirectCookieName = sprintf('pjax_redirect_%s', $request->headers->get('X-PJAX-Target'));
         $redirectTo = $response->headers->get('Location');
         $response->headers->setCookie(new Cookie(rawurlencode($redirectCookieName), $redirectTo, 0, '/', null, false, false));
     }
     return $response;
 }
 public function test_it_should_add_cookie_on_redirect()
 {
     $event = $this->prophesize('Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent');
     $request = $this->prophesize('\\Symfony\\Component\\HttpFoundation\\Request');
     $requestHeaders = $this->prophesize('\\Symfony\\Component\\HttpFoundation\\HeaderBag');
     $request->headers = $requestHeaders->reveal();
     $response = $this->prophesize('Symfony\\Component\\HttpFoundation\\Response');
     $headers = $this->prophesize('\\Symfony\\Component\\HttpFoundation\\ResponseHeaderBag');
     $response->headers = $headers->reveal();
     $event->getRequest()->willReturn($request->reveal());
     $event->getResponse()->willReturn($response->reveal());
     $this->pjax->isPjaxRequest($request->reveal())->willReturn(true);
     $response->isRedirect()->wilLReturn(true);
     $headers->get('Location')->willReturn('redirect_uri');
     $headers->setCookie(Argument::any())->shouldBeCalled();
     $this->listener->pjaxRedirect($event->reveal());
 }
 /**
  * @param Request $request
  *
  * @return string
  */
 public function getPjaxTarget(Request $request)
 {
     return $this->pjax->getTarget($request);
 }