<?php
namespace App\Controller\Front;
use App\Entity\Project;
use App\Repository\ContentRepository;
use App\Repository\ProjectRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class HomeController extends AbstractController
{
/**
* @Route("/{_locale}", defaults={"_locale"="fr"}, name="front_home")
*/
public function home(string $_locale, ContentRepository $contentRepository, ProjectRepository $projectRepository)
{
return $this->render('front/home.html.twig', [
'contentHeader' => $contentRepository->findOneBy(['page' => 'home', 'section' => 'header', 'lang' => $_locale]),
'contentBlock1' => $contentRepository->findOneBy(['page' => 'home', 'section' => 'block1', 'lang' => $_locale]),
'contentBlock2' => $contentRepository->findOneBy(['page' => 'home', 'section' => 'block2', 'lang' => $_locale]),
'contentBlock3' => $contentRepository->findOneBy(['page' => 'home', 'section' => 'block3', 'lang' => $_locale]),
'contentBlock4' => $contentRepository->findOneBy(['page' => 'home', 'section' => 'block4', 'lang' => $_locale]),
'contentBlock5' => $contentRepository->findOneBy(['page' => 'home', 'section' => 'block5', 'lang' => $_locale]),
'latestProjects' => $projectRepository->findBy(['isPublished' => Project::PROJECT_PUBLISHED], ['id' => 'DESC'], 5)
]);
}
}