<?php
declare(strict_types=1);
namespace App\Controller\Front;
use App\Entity\PostType\Actualite\Actualite;
use App\Entity\PostType\PostType;
use App\Repository\PostTypeRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class ActualiteController extends AbstractController
{
#[Route('/', name: 'app_front_actualite_index', methods: ['GET'])]
public function index(
PostTypeRepository $postTypeRepository
): Response {
return $this->render('front/index.html.twig', [
'page' => $postTypeRepository->find(PostType::INDEX),
'controller_name' => 'PageController',
]);
}
#[Route('/actualite/{name}', name: 'app_front_actualite_detail', methods: ['GET'])]
public function page(Actualite $actualite): Response
{
if (
PostType::STATUS_PUBLISHED !== $actualite->getStatus()
&& !$this->isGranted('ROLE_ADMIN')
) {
throw $this->createNotFoundException('The page does not exist.');
}
return $this->render('front/actualite/detail.html.twig', [
'actualite' => $actualite,
]);
}
}