src/Controller/PageController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\DTO\AppDTO;
  4. use App\Service\Cache\Cache;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\RequestStack;
  8. use App\RepositoryInterface\PageRepositoryInterface;
  9. class PageController extends AbstractASController
  10. {
  11.     //Repositories
  12.     protected PageRepositoryInterface $Pages;
  13.     public function __construct(PageRepositoryInterface $PagesRequestStack $requestStack)
  14.     {
  15.         $this->requestStack $requestStack;
  16.         $this->Pages $Pages;
  17.     }
  18.         
  19.     #[Route(path'/{page_intname}'name'static_page_no_locale'defaults: ['_locale' => '%app.default_lang%'])]
  20.     #[Route(path'/{_locale}/{page_intname}'name'static_page'requirements: ['_locale' => '%app.langs%'])]
  21.     public function index(string $page_intnameAppDTO $app): Response
  22.     {
  23.         $page $this->Pages->getByName($page_intname);
  24.         if (!$page) {
  25.             throw $this->createNotFoundException();
  26.         }
  27.         $response $this->render('page/static.html.twig', [
  28.             'page_name' => $page_intname,
  29.             'page' => $page,
  30.             'pageblocks' => $page->getBlocks(),
  31.             'photos' => $page->getPhotos(),
  32.             'controller_name' => 'PageController',
  33.         ]);
  34.         $response Cache::http($response$this->getParameter('app.http_cache_time'));
  35.         return $response;
  36.     }
  37. }