<?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;

#[Route('/render/feature', name: 'render_feature_')]
final class RenderFeatureController extends AbstractController
{
    private EntityManagerInterface $entityManager;

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

    #[Route('/news', name: 'news')]
    public function news($isCarousel): Response
    {
        $news = $this->entityManager->getRepository(News::class)->findBy([], ['ordre' => 'ASC']);
        return $this->render('render_feature/news.html.twig', [
            'news' => $news,
            'isCarousel' => $isCarousel
        ]);
    }
}
