<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Http\Event\LogoutEvent;
class KioskLogoutSubscriber implements EventSubscriberInterface
{
protected $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function onLogout(LogoutEvent $event): void
{
$request = $event->getRequest();
$mode = $request->query->get('mode');
$parameters = [];
if ($mode === 'kiosk') {
$parameters['mode'] = 'kiosk';
}
$response = new RedirectResponse(
$this->router->generate('app_login', $parameters),
RedirectResponse::HTTP_SEE_OTHER
);
$event->setResponse($response);
}
public static function getSubscribedEvents(): array
{
return [
LogoutEvent::class => 'onLogout',
];
}
}