vendor/symfony/security-http/EventListener/CsrfTokenClearingLogoutListener.php line 32

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\EventListener;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\Security\Csrf\TokenStorage\ClearableTokenStorageInterface;
  13. use Symfony\Component\Security\Http\Event\LogoutEvent;
  14. /**
  15.  * @author Christian Flothmann <christian.flothmann@sensiolabs.de>
  16.  *
  17.  * @final
  18.  */
  19. class CsrfTokenClearingLogoutListener implements EventSubscriberInterface
  20. {
  21.     private $csrfTokenStorage;
  22.     public function __construct(ClearableTokenStorageInterface $csrfTokenStorage)
  23.     {
  24.         $this->csrfTokenStorage $csrfTokenStorage;
  25.     }
  26.     public function onLogout(LogoutEvent $event): void
  27.     {
  28.         $this->csrfTokenStorage->clear();
  29.     }
  30.     public static function getSubscribedEvents(): array
  31.     {
  32.         return [
  33.             LogoutEvent::class => 'onLogout',
  34.         ];
  35.     }
  36. }