vendor/symfony/security-http/EventListener/SessionLogoutListener.php line 29

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <[email protected]>
  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\Http\Event\LogoutEvent;
  13. /**
  14. * Handler for clearing invalidating the current session.
  15. *
  16. * @author Johannes M. Schmitt <[email protected]>
  17. *
  18. * @final
  19. */
  20. class SessionLogoutListener implements EventSubscriberInterface
  21. {
  22. public function onLogout(LogoutEvent $event): void
  23. {
  24. if ($event->getRequest()->hasSession()) {
  25. $event->getRequest()->getSession()->invalidate();
  26. }
  27. }
  28. public static function getSubscribedEvents(): array
  29. {
  30. return [
  31. LogoutEvent::class => 'onLogout',
  32. ];
  33. }
  34. }