<?php
namespace Boab\CmsBundle\Security;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Http\Event\LogoutEvent;
class LogoutListener
{
private RouterInterface $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
/**
* @param LogoutEvent $logoutEvent
* @return void
*/
public function onLogout(LogoutEvent $event): void
{
$referer = $event->getRequest()->headers->get('referer');
dump($referer);
$event->setResponse(new RedirectResponse($this->router->generate('boabcms_admin_login')));
//$logoutEvent->setResponse(new RedirectResponse('https://where-you-want-to-redirect.com', Response::HTTP_MOVED_PERMANENTLY));
}
}