lib/boab/cms-bundle/src/Security/LogoutListener.php line 21

Open in your IDE?
  1. <?php 
  2. namespace Boab\CmsBundle\Security;
  3. use Symfony\Component\Routing\RouterInterface;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\Security\Http\Event\LogoutEvent;
  6. class LogoutListener
  7. {
  8.     private RouterInterface $router;
  9.     public function __construct(RouterInterface $router)
  10.     {
  11.         $this->router $router;
  12.     }
  13.     /**
  14.      * @param LogoutEvent $logoutEvent
  15.      * @return void
  16.      */
  17.     public function onLogout(LogoutEvent $event): void
  18.     {
  19.         $referer $event->getRequest()->headers->get('referer');
  20.         dump($referer);
  21.         $event->setResponse(new RedirectResponse($this->router->generate('boabcms_admin_login')));
  22.         //$logoutEvent->setResponse(new RedirectResponse('https://where-you-want-to-redirect.com', Response::HTTP_MOVED_PERMANENTLY));
  23.     }
  24. }