src/Controller/front/Home/HomeController.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Controller\front\Home;
  3. use App\Controller\Admin\CoreController;
  4. use App\Repository\LanguagesRepository;
  5. use App\Repository\Pages\PageCategoryRepository;
  6. use App\Repository\Pages\PageRepository;
  7. use App\Service\Manager\Blocs\BlocManager;
  8. use App\Service\Manager\Media\MediaManager;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use App\Service\Manager\Pages\PaletteColorsManager;
  13. class HomeController extends CoreController
  14. {
  15.     
  16.     #[Route('/'name'front_home')]
  17.     public function index(PageRepository $pageRepository,
  18.                           BlocManager $blocManager,
  19.                           MediaManager $mediaManager,
  20.                           PaletteColorsManager $paletteColorsManager
  21.                           ): Response
  22.     {
  23.         $page $pageRepository->find($this->getParameter('id_home_page'));  
  24.         $blocs $blocManager->getBlocs($page);
  25.         $paletteColors $paletteColorsManager->getValues('App\\Entity\\Pages\\Page',$page->getId());
  26.         $colorPage=null;
  27.         if($paletteColors){
  28.             $colorPage=$paletteColors[0];
  29.         }
  30.         //$blocHeader = $blocManager->getBlocsSliderHeader($page);
  31.         return $this->render('front/pages/home/index.html.twig', [
  32.             'blocs'  => $blocs,
  33.             'page'   => $pageRepository->detailPage($this->getCurrentLanguage(), ['id' => $this->getParameter('id_home_page'), 'media_page' => true]),
  34.             'paletteColors' =>$colorPage,
  35.             //'blocHeader' => $blocHeader
  36.         ]);
  37.     }
  38.     #[Route('/check_value'name'check_value')] 
  39.     public function checkValue(
  40.             Request $request
  41.             LanguagesRepository $languagesRepository
  42.             PageCategoryRepository $pageCategoryRepository,
  43.             PageRepository $pageRepository
  44.         ){
  45.         $route $request->request->get('route');
  46.         $slug $request->request->get('slug');
  47.         $localeCurrent $request->request->get('localeCurrent');
  48.         $langSelected $request->request->get('langSelected');
  49.         if($route == "front_page_category_show"){
  50.             $slug $pageCategoryRepository->findSlugWithLanguage(
  51.                 $languagesRepository->findOneByCode($localeCurrent), 
  52.                 [
  53.                     'slug' => $slug,
  54.                     'langSelected' => $languagesRepository->findOneByCode($langSelected
  55.                 ]
  56.             );
  57.         }
  58.         else if ($route == "front_page_show"){
  59.             $slug $pageRepository->findSlugWithLanguage(
  60.                 $languagesRepository->findOneByCode($localeCurrent), 
  61.                 [
  62.                     'slug' => $slug,
  63.                     'langSelected' => $languagesRepository->findOneByCode($langSelected
  64.                 ]
  65.             );
  66.         }
  67.      
  68.         return new Response($slug);
  69.     }
  70. }