src/Controller/Front/ActualiteController.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\Front;
  4. use App\Entity\PostType\Actualite\Actualite;
  5. use App\Entity\PostType\PostType;
  6. use App\Repository\PostTypeRepository;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class ActualiteController extends AbstractController
  11. {
  12.     #[Route('/'name'app_front_actualite_index'methods: ['GET'])]
  13.     public function index(
  14.         PostTypeRepository $postTypeRepository
  15.     ): Response {
  16.         return $this->render('front/index.html.twig', [
  17.             'page' => $postTypeRepository->find(PostType::INDEX),
  18.             'controller_name' => 'PageController',
  19.         ]);
  20.     }
  21.     #[Route('/actualite/{name}'name'app_front_actualite_detail'methods: ['GET'])]
  22.     public function page(Actualite $actualite): Response
  23.     {
  24.         if (
  25.             PostType::STATUS_PUBLISHED !== $actualite->getStatus()
  26.             && !$this->isGranted('ROLE_ADMIN')
  27.         ) {
  28.             throw $this->createNotFoundException('The page does not exist.');
  29.         }
  30.         return $this->render('front/actualite/detail.html.twig', [
  31.             'actualite' => $actualite,
  32.         ]);
  33.     }
  34. }