vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/EventListener/FirewallListener.php line 51

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\Bundle\SecurityBundle\EventListener;
  11. use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
  12. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  13. use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
  14. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  15. use Symfony\Component\Security\Http\Firewall;
  16. use Symfony\Component\Security\Http\FirewallMapInterface;
  17. use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
  18. /**
  19.  * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
  20.  */
  21. class FirewallListener extends Firewall
  22. {
  23.     private $map;
  24.     private $logoutUrlGenerator;
  25.     public function __construct(FirewallMapInterface $mapEventDispatcherInterface $dispatcherLogoutUrlGenerator $logoutUrlGenerator)
  26.     {
  27.         $this->map $map;
  28.         $this->logoutUrlGenerator $logoutUrlGenerator;
  29.         parent::__construct($map$dispatcher);
  30.     }
  31.     public function onKernelRequest(GetResponseEvent $event)
  32.     {
  33.         if (!$event->isMasterRequest()) {
  34.             return;
  35.         }
  36.         if ($this->map instanceof FirewallMap && $config $this->map->getFirewallConfig($event->getRequest())) {
  37.             $this->logoutUrlGenerator->setCurrentFirewall($config->getName(), $config->getContext());
  38.         }
  39.         parent::onKernelRequest($event);
  40.     }
  41.     public function onKernelFinishRequest(FinishRequestEvent $event)
  42.     {
  43.         if ($event->isMasterRequest()) {
  44.             $this->logoutUrlGenerator->setCurrentFirewall(null);
  45.         }
  46.         parent::onKernelFinishRequest($event);
  47.     }
  48. }