✨ feat(Security): Crée un listener pour rediriger la racine du domaine de réservation.
This commit is contained in:
33
src/Security/RedirecListener.php
Normal file
33
src/Security/RedirecListener.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Security;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\RequestEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Twig\Environment;
|
||||
|
||||
#[AsEventListener(event: ResponseEvent::class,method: 'onResponse')]
|
||||
class RedirecListener
|
||||
{
|
||||
|
||||
|
||||
|
||||
public function onResponse(ResponseEvent $event): void
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
if($request->getPathInfo() == "/") {
|
||||
if($request->getHost() =="reservation.ludikevent.fr"){
|
||||
$redirect = new RedirectResponse("https://reservation.ludikevent.fr/reservation");
|
||||
$event->setResponse($redirect);
|
||||
$event->stopPropagation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user