vendor/symfony/security-bundle/EventListener/FirewallListener.php line 46

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.     private $map;
  23.     private $logoutUrlGenerator;
  24.     public function __construct(FirewallMapInterface $mapEventDispatcherInterface $dispatcherLogoutUrlGenerator $logoutUrlGenerator) {
  25.         $this->map $map;
  26.         $this->logoutUrlGenerator $logoutUrlGenerator;
  27.         parent::__construct($map$dispatcher);
  28.     }
  29.     public function onKernelRequest(GetResponseEvent $event) {
  30.         if (!$event->isMasterRequest()) {
  31.             return;
  32.         }
  33.         if ($this->map instanceof FirewallMap && $config $this->map->getFirewallConfig($event->getRequest())) {
  34.             $this->logoutUrlGenerator->setCurrentFirewall($config->getName(), $config->getContext());
  35.         }
  36.         parent::onKernelRequest($event);
  37.     }
  38.     public function onKernelFinishRequest(FinishRequestEvent $event) {
  39.         if ($event->isMasterRequest()) {
  40.             $this->logoutUrlGenerator->setCurrentFirewall(null);
  41.         }
  42.         parent::onKernelFinishRequest($event);
  43.     }
  44. }