<?php
namespace App\Controller\front\Home;
use App\Controller\Admin\CoreController;
use App\Repository\LanguagesRepository;
use App\Repository\Pages\PageCategoryRepository;
use App\Repository\Pages\PageRepository;
use App\Service\Manager\Blocs\BlocManager;
use App\Service\Manager\Media\MediaManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Service\Manager\Pages\PaletteColorsManager;
class HomeController extends CoreController
{
#[Route('/', name: 'front_home')]
public function index(PageRepository $pageRepository,
BlocManager $blocManager,
MediaManager $mediaManager,
PaletteColorsManager $paletteColorsManager
): Response
{
$page = $pageRepository->find($this->getParameter('id_home_page'));
$blocs = $blocManager->getBlocs($page);
$paletteColors = $paletteColorsManager->getValues('App\\Entity\\Pages\\Page',$page->getId());
$colorPage=null;
if($paletteColors){
$colorPage=$paletteColors[0];
}
//$blocHeader = $blocManager->getBlocsSliderHeader($page);
return $this->render('front/pages/home/index.html.twig', [
'blocs' => $blocs,
'page' => $pageRepository->detailPage($this->getCurrentLanguage(), ['id' => $this->getParameter('id_home_page'), 'media_page' => true]),
'paletteColors' =>$colorPage,
//'blocHeader' => $blocHeader
]);
}
#[Route('/check_value', name: 'check_value')]
public function checkValue(
Request $request,
LanguagesRepository $languagesRepository,
PageCategoryRepository $pageCategoryRepository,
PageRepository $pageRepository
){
$route = $request->request->get('route');
$slug = $request->request->get('slug');
$localeCurrent = $request->request->get('localeCurrent');
$langSelected = $request->request->get('langSelected');
if($route == "front_page_category_show"){
$slug = $pageCategoryRepository->findSlugWithLanguage(
$languagesRepository->findOneByCode($localeCurrent),
[
'slug' => $slug,
'langSelected' => $languagesRepository->findOneByCode($langSelected)
]
);
}
else if ($route == "front_page_show"){
$slug = $pageRepository->findSlugWithLanguage(
$languagesRepository->findOneByCode($localeCurrent),
[
'slug' => $slug,
'langSelected' => $languagesRepository->findOneByCode($langSelected)
]
);
}
return new Response($slug);
}
}