src/Controller/PageController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Page;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class PageController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/{uri}.html", name="page", requirements={"uri"=".*"}, priority=-100)
  11.      * @param string $uri
  12.      * @return Response
  13.      * @throws \Exception
  14.      */
  15.     public function index(string $uri): Response
  16.     {
  17.         $page $this->getDoctrine()->getRepository(Page::class)->findOneBy(['uri' => $uri'published' => true]);
  18.         if (empty($page)) {
  19.             throw $this->createNotFoundException();
  20.         }
  21.         return $this->render($page->getTemplate()->getPath(), ['page' => $page]);
  22.     }
  23. }