src/Controller/LandingController.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request// ðŸ‘ˆ Importamos la clase Request
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class LandingController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/", name="app_landing")
  11.      */
  12.     public function index(Request $request): Response // ðŸ‘ˆ Inyectamos Request aquí
  13.     {
  14.         // 1. Atrapamos el código 'c' que viene en la URL
  15.         $codigoQr $request->query->get('c');
  16.         // Si no hay código QR en la URL (ej. entran a la raíz directo), redirigir al login
  17.         if (!$codigoQr) {
  18.             return $this->redirectToRoute('app_login');
  19.         }
  20.         // 2. Pasamos esa variable a tu plantilla Twig
  21.         /*return $this->render('landing/index.html.twig', [
  22.             'codigo_qr' => $codigoQr,
  23.         ]);*/
  24.         return $this->render('landing/landing_global.html.twig', [
  25.             'codigo_qr' => $codigoQr,
  26.         ]);
  27.     }
  28. }