vendor/symfony/security-http/RememberMe/ResponseListener.php line 25

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\Security\Http\RememberMe;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
  13. use Symfony\Component\HttpKernel\KernelEvents;
  14. /**
  15.  * Adds remember-me cookies to the Response.
  16.  *
  17.  * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  18.  */
  19. class ResponseListener implements EventSubscriberInterface {
  20.     public function onKernelResponse(FilterResponseEvent $event) {
  21.         if (!$event->isMasterRequest()) {
  22.             return;
  23.         }
  24.         $request $event->getRequest();
  25.         $response $event->getResponse();
  26.         if ($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)) {
  27.             $response->headers->setCookie($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME));
  28.         }
  29.     }
  30.     /**
  31.      * {@inheritdoc}
  32.      */
  33.     public static function getSubscribedEvents() {
  34.         return [KernelEvents::RESPONSE => 'onKernelResponse'];
  35.     }
  36. }