<?php
namespace App\Controller;
use App\Entity\Header;
use App\Repository\AboutRepository;
use App\Repository\HeaderRepository;
use App\Repository\NewsRepository;
use App\Repository\TitlesRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends AbstractController
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
/**
* @Route("/{_locale<%app.supported_locales%>}/", name="app_main")
*/
public function index(HeaderRepository $headerRepository, AboutRepository $aboutRepository, TitlesRepository $titlesRepository, NewsRepository $newsRepository): Response
{
$header = $headerRepository->findByIsActive(1);
$new = $newsRepository->findByIsActive(1);
$inter1 = $titlesRepository->findTitleByTag('intervention_1');
$inter2 = $titlesRepository->findTitleByTag('intervention_2');
$inter3 = $titlesRepository->findTitleByTag('intervention_3');
$inter4 = $titlesRepository->findTitleByTag('intervention_4');
$success = $titlesRepository->findTitleByTag('success_index');
$about = $aboutRepository->findAboutByTag('about_home');
return $this->render('main/index.html.twig', [
'headers' => $header,
'aboutHome' => $about,
'success' => $success,
'inter1' => $inter1,
'inter2' => $inter2,
'inter3' => $inter3,
'inter4' => $inter4,
'news' => $new
]);
}
/**
* @Route("/")
*/
public function indexNoLocale(): Response {
return $this->redirectToRoute('app_main', ['_locale'=>'fr']);
}
}