<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class RedirectController extends AbstractController
{
    #[Route('/external-redirect', name: 'app_external_redirect', methods: ['GET'])]
    public function warning(Request $request): Response
    {
        $url = $request->query->get('redirUrl');

        if (!$url) {
            return $this->redirectToRoute('app_home');
        }

        return $this->render('pages/external_redirect.twig', [
            'url' => $url,
            'breadcrumbs' => [
                ['name' => 'Accueil', 'url' => '/'],
                ['name' => 'Redirection externe', 'url' => '/external-redirect'],
            ],
        ]);
    }
}
