src/Controller/HomeController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Twig\Environment;
  8. class HomeController extends AbstractController
  9. {
  10.     public function __construct(Environment $twig)
  11.     {
  12.         $this->loader $twig->getLoader();
  13.     }
  14.     #[Route('/'name'home')]
  15.     public function index(): Response
  16.     {
  17.         return $this->render('index.html.twig');
  18.     }
  19.     #[Route('/{path}')]
  20.     public function root($path)
  21.     {
  22.         if ($this->loader->exists($path.'.html.twig')) {
  23.             if ($path == '/' || $path == 'home') {
  24.                 die('Home');
  25.             }
  26.             return $this->render($path.'.html.twig');
  27.         }
  28.         throw $this->createNotFoundException('The Requested Page Not Found.');
  29.     }
  30. }