<?php

namespace App\Controller;

use App\Entity\News;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

final class PageController extends AbstractController
{
    private EntityManagerInterface $entityManager;

    public function __construct(EntityManagerInterface $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    #[Route('/', name: 'home')]
    public function index(): Response
    {
        return $this->render('page/home.html.twig', []);
    }

    #[Route('/a-propos', name: 'about')]
    public function about(): Response
    {
        return $this->render('page/about.html.twig', []);
    }

    #[Route('/projets-artistiques', name: 'project')]
    public function project(): Response
    {
        return $this->render('page/project.html.twig', []);
    }

    #[Route('/projets-manuels-et-creatifs', name: 'manualproject')]
    public function manualproject(): Response
    {
        return $this->render('page/manual-project.html.twig', []);
    }

    #[Route('/show', name: 'show')]
    public function show(): Response
    {
        return $this->render('page/show.html.twig', []);
    }

    #[Route('/mentions-legales', name: 'legalmentions')]
    public function legalmentions(): Response
    {
        return $this->render('page/legal-mentions.html.twig', []);
    }

    #[Route('/politique-de-confidentialite', name: 'confidentialitypolicy')]
    public function confidentialitypolicy(): Response
    {
        return $this->render('page/confidentiality-policy.html.twig', []);
    }

    #[Route('/actualites/{slug}', name: 'actualites')]
    public function actualites(string $slug): Response
    {
        $news = $this->entityManager->getRepository(News::class)->findOneBy(['slug' => $slug]);
        return $this->render('page/news.html.twig', ['news' => $news]);
    }
}
