src/Controller/RankingController.php line 387

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\DescriptionRepository;
  4. use App\Entity\RankingLignes;
  5. use App\Repository\CommuneRepository;
  6. use App\Repository\ProvinceRepository;
  7. use App\Repository\RubriqueRepository;
  8. use App\Repository\CommercesRepository;
  9. use App\Repository\RankingRepository;
  10. use App\Repository\RankingPhotosRepository;
  11. use App\Repository\RankingLignesRepository;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use Doctrine\ORM\Query\ResultSetMapping;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Symfony\Component\HttpFoundation\JsonResponse;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Twig\Environment;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  21. use Symfony\Component\HttpFoundation\Session\Session;
  22. class RankingController extends AbstractController
  23. {
  24.     private $em;
  25.     /**
  26.      * @var Environment
  27.      */
  28.     private $twig;
  29.     /**
  30.      * @var CommuneRepository
  31.      */
  32.     private $communeRepository;
  33.     /**
  34.      * @var ProvinceRepository
  35.      */
  36.     private $provinceRepository;
  37.     /**
  38.      * @var RankingRepository
  39.      */
  40.     private $rankingRepository;
  41.     /**
  42.      * @var RankingLignesRepository
  43.      */
  44.     private $rankingLignesRepository;
  45.     /**
  46.      * @var CommercesRepository
  47.      */
  48.     private $CommercesRepository;
  49.     /**
  50.      * @var RankingPhotosRepository
  51.      */
  52.     private $rankingPhotoRepository;
  53.     /**
  54.      * @var RubriqueRepository
  55.      */
  56.     private $rubriqueRepository;
  57.     /**
  58.      * @var DescriptionRepository
  59.      */
  60.     private $descriptionRepository;
  61.     private $breadcrumb;
  62.     private $session ;
  63.     public function __construct(Environment $twig,
  64.                                 EntityManagerInterface $em,
  65.                                 CommuneRepository $communeRepository,
  66.                                 DescriptionRepository $descriptionRepository,
  67.                                 ProvinceRepository $ProvinceRepository,
  68.                                 RankingRepository $RankingRepository,
  69.                                 RankingLignesRepository $rankingLignesRepository,
  70.                                 RankingPhotosRepository $rankingPhotoRepository,
  71.                                 RubriqueRepository $rubriqueRepository,
  72.                                 CommercesRepository $CommercesRepository)
  73.     {
  74.         $this->twig $twig;
  75.         $this->em $em;
  76.         $this->descriptionRepository $descriptionRepository;
  77.         $this->communeRepository $communeRepository;
  78.         $this->provinceRepository $ProvinceRepository;
  79.         $this->rankingRepository $RankingRepository;
  80.         $this->rankingLignesRepository $rankingLignesRepository;
  81.         $this->CommercesRepository $CommercesRepository;
  82.         $this->rankingPhotoRepository $rankingPhotoRepository;
  83.         $this->rubriqueRepository $rubriqueRepository;
  84.         $this->breadcrumb=[];
  85.     }
  86.     /**
  87.      * @Route("/rubrique+{slug}.html",name="rubrique_ranking", requirements={"slug"="[^+]+",  "rubrique_slug"="[^+]+"})
  88.      */
  89.     public function index($slugRequest $request): Response
  90.     {
  91.         $rubrique$this->rubriqueRepository->findOneBySlug($slug);
  92.         if(!$rubrique){
  93.             return $this->redirectToRoute('rubrique_text',array('text'=>$slug));
  94.         }
  95.         $communee $this->communeRepository->find30Communee();
  96.         $id=!empty($rubrique) ? $rubrique->getId() : null;
  97.         $rubrique_name=!empty($rubrique) ?$rubrique->getRubrique() : null;
  98.         $rubrique_slug=!empty($rubrique) ? $rubrique->getSlugNom() :null;
  99.         $list_ranking $id != null $this->rankingRepository->findByIdRubrique($id) : '';
  100.         $lignes $this->rankingLignesRepository->findAll();
  101.         $photos $this->rankingPhotoRepository->findAll();
  102.         $list_commcartesvisites $id != null $this->CommercesRepository->getCartVisitCommerces($id): '';
  103.         $list_coloredComm $id != null $this->CommercesRepository->getColoredCommerces($id): '';
  104.         $list_freeComm $id != null $this->CommercesRepository->getFreeCommerces($id): '';
  105.         $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  106.         $meta_title $rubrique_name " Atout Commerces annuaire des commerçants et artisans en Wallonie | Atout-Commerces.be";
  107.         $meta_description "Liste complète des " $rubrique_name ". Atout Commerces est un annuaire des commerçants, artisans, professions libérales, et entrepreneurs. 100.000 professionnels référencés. Retrouvez tous les " $rubrique_name " en Wallonie.";
  108.         //new rubrique ajax
  109.         $list_ranking1 $id != null $this->rankingRepository->findByIdRubriqueAndLevel($id,1): '';
  110.         $list_ranking2 $id != null $this->rankingRepository->findByIdRubriqueAndLevel($id,2): '';
  111.         $list_ranking3 $id != null $this->rankingRepository->findByIdRubriqueAndLevel($id,3): '';
  112.         shuffle($list_ranking1);
  113.         shuffle($list_ranking2);
  114.         shuffle($list_ranking3);
  115.         $linkFR"fr/rubrique+" $slug ".html";
  116.         $linkNL=!empty($rubrique) ?$rubrique->getRubriqueNL() : null;
  117.         $linkNL"nl/rubrique+" $linkNL ".html";
  118.         $slug_commune $this->communeRepository->findAll();
  119.         //rubrique state already exists
  120.         if ($request->query->get('l')=="get"){
  121.             return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  122.                 [
  123.                     'list_ranking' => $list_ranking,
  124.                     'list_commcartesvisites' => $list_commcartesvisites,
  125.                     'list_coloredComm' => $list_coloredComm,
  126.                     'list_freeComm' => $list_freeComm,
  127.                     'lignes' => $lignes,
  128.                     'photos' => $photos,
  129.                     'idc' => null,
  130.                     'idp' => null,
  131.                     'rubrique_name' => $rubrique_name,
  132.                     'ou' => null,
  133.                     //'name'=>$rubrique_name,
  134.                     'rubrique_slug' => $rubrique_slug,
  135.                     'meta_title' => $meta_title,
  136.                     'meta_description' => $meta_description,
  137.                     'commune_nom' => null,
  138.                     'total_results' => $total_results,
  139.                     'province_obj' => null,
  140.                     'textCommercial'=>false,
  141.                     'noindex'=>count($list_ranking) >=20,
  142.                     'rubriqueobjet' =>$rubrique $rubrique null,
  143.                     'communee'=>$communee,
  144.                     'slug_commune'=>$slug_commune,
  145.                     'linkNL' => $linkNL,
  146.                     'linkFR' => $linkFR,
  147.                 ]));
  148.         }
  149.         if (count($list_ranking) < 20){
  150.             return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  151.                 [
  152.                     'list_ranking' => $list_ranking,
  153.                     'list_commcartesvisites' => $list_commcartesvisites,
  154.                     'list_coloredComm' => $list_coloredComm,
  155.                     'list_freeComm' => $list_freeComm,
  156.                     'lignes' => $lignes,
  157.                     'photos' => $photos,
  158.                     'idc' => null,
  159.                     'idp' => null,
  160.                     'rubrique_name' => $rubrique_name,
  161.                     'ou' => null,
  162.                     //'name'=>$rubrique_name,
  163.                     'rubrique_slug' => $rubrique_slug,
  164.                     'meta_title' => $meta_title,
  165.                     'meta_description' => $meta_description,
  166.                     'commune_nom' => null,
  167.                     'total_results' => $total_results,
  168.                     'province_obj' => null,
  169.                     'textCommercial'=>false,
  170.                     'noindex'=>count($list_ranking) >=20,
  171.                     'rubriqueobjet' =>$rubrique $rubrique null,
  172.                     'communee'=>$communee,
  173.                     'slug_commune'=>$slug_commune,
  174.                     'linkNL' => $linkNL,
  175.                     'linkFR' => $linkFR,
  176.                 ]));
  177.         }
  178.         if (count($list_ranking) > 20){
  179.             return new Response($this->twig->render('Results_Search/new-rubrique-ajax.html.twig',
  180.                 [
  181.                     'idr'=>$id,
  182.                     'idc'=>null,
  183.                     'rubriqueobjet' =>$rubrique $rubrique null,
  184.                     'rubrique_name'=>$rubrique_name,
  185.                     'ou'=>null,
  186.                     'rubrique_slug'=>$rubrique_slug,
  187.                     'meta_title' => $meta_title,
  188.                     'meta_description' => $meta_description,
  189.                     'slug_rub' => $slug,
  190.                     'total_results'=>$total_results,
  191.                     'textCommercial'=>false,
  192.                     'list_ranking'=>$list_ranking,
  193.                     'list_ranking1'=>$list_ranking1,
  194.                     'list_ranking2'=>$list_ranking2,
  195.                     'list_ranking3'=>$list_ranking3,
  196.                     'lignes'=>$lignes,
  197.                     'photos'=>$photos,
  198.                     'list_commcartesvisites'=>$list_commcartesvisites,
  199.                     'list_coloredComm'=>$list_coloredComm,
  200.                     'list_freeComm'=>$list_freeComm,
  201.                     'communee'=>$communee,
  202.                     'slug_commune'=>$slug_commune,
  203.                     'linkNL' => $linkNL,
  204.                     'linkFR' => $linkFR,
  205.                 ]));
  206.         }
  207.         return new Response($this->twig->render('Results_Search/new-rubrique-ajax.html.twig',
  208.             [
  209.                 'idr'=>$id,
  210.                 'idc'=>null,
  211.                 'rubriqueobjet' =>$rubrique $rubrique null,
  212.                 'rubrique_name'=>$rubrique_name,
  213.                 'ou'=>null,
  214.                 'rubrique_slug'=>$rubrique_slug,
  215.                 'meta_title' => $meta_title,
  216.                 'meta_description' => $meta_description,
  217.                 'slug_rub' => $slug,
  218.                 'total_results'=>$total_results,
  219.                 'textCommercial'=>false,
  220.                 'list_ranking'=>$list_ranking,
  221.                 'list_ranking1'=>$list_ranking1,
  222.                 'list_ranking2'=>$list_ranking2,
  223.                 'list_ranking3'=>$list_ranking3,
  224.                 'lignes'=>$lignes,
  225.                 'photos'=>$photos,
  226.                 'list_commcartesvisites'=>$list_commcartesvisites,
  227.                 'list_coloredComm'=>$list_coloredComm,
  228.                 'list_freeComm'=>$list_freeComm,
  229.                 'communee'=>$communee,
  230.                 'slug_commune'=>$slug_commune,
  231.                 'linkNL' => $linkNL,
  232.                 'linkFR' => $linkFR,
  233.             ]));
  234.     }
  235.     /**
  236.      * @Route("/rubrique_stats/{slug_rub}",name="rubrique_stats")
  237.      */
  238.     public function rubrique_stats($slug_rub)
  239.     {
  240.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rub);
  241.         $id=!empty($rubrique) ? $rubrique->getId() : null;
  242.         $rubrique_name=!empty($rubrique) ?$rubrique->getRubrique() : null;
  243.         $rubrique_slug=!empty($rubrique) ? $rubrique->getSlugNom() :null;
  244.         $list_ranking $id != null $this->rankingRepository->findByIdRubrique($id) : '';
  245.         $list_commcartesvisites $id != null $this->CommercesRepository->getCartVisitCommerces($id): '';
  246.         $list_coloredComm $id != null $this->CommercesRepository->getColoredCommerces($id): '';
  247.         $list_freeComm $id != null $this->CommercesRepository->getFreeCommerces($id): '';
  248.         return new JsonResponse([
  249.             'html' => $this->renderView('Results_Search/template-parts/rubrique_stats.html.twig', [
  250.                 'list_ranking'=>$list_ranking,
  251.                 'list_commcartesvisites'=>$list_commcartesvisites,
  252.                 'list_coloredComm'=>$list_coloredComm,
  253.                 'list_freeComm'=>$list_freeComm,
  254.                 'rubrique_name'=>$rubrique_name,
  255.                 'rubrique_slug'=>$rubrique_slug,
  256.                 'ou'=>null,
  257.                 'idc'=>null,
  258.                 'idr'=>$id,
  259.                 'rubriqueobjet' =>$rubrique $rubrique null,
  260.             ]),
  261.         ]);
  262.     }
  263.     /**
  264.      * @Route("/list_ranking/{slug_rub}",name="list_ranking")
  265.      */
  266.     public function list_ranking($slug_rub)
  267.     {
  268.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rub);
  269.         $id=!empty($rubrique) ? $rubrique->getId() : null;
  270.         $rubrique_name=!empty($rubrique) ?$rubrique->getRubrique() : null;
  271.         $rubrique_slug=!empty($rubrique) ? $rubrique->getSlugNom() :null;
  272.         $list_ranking $id != null $this->rankingRepository->findByIdRubrique($id) : '';
  273.         $list_ranking1 $id != null $this->rankingRepository->findByIdRubriqueAndLevel($id,1): '';
  274.         $list_ranking2 $id != null $this->rankingRepository->findByIdRubriqueAndLevel($id,2): '';
  275.         $list_ranking3 $id != null $this->rankingRepository->findByIdRubriqueAndLevel($id,3): '';
  276.         shuffle($list_ranking1);
  277.         shuffle($list_ranking2);
  278.         shuffle($list_ranking3);
  279.         $lignes$this->rankingLignesRepository->findAll();
  280.         $photos$this->rankingPhotoRepository->findAll();
  281.         return new JsonResponse([
  282.             'html' => $this->renderView('Results_Search/template-parts/list_ranking.html.twig', [
  283.                 'list_ranking'=>$list_ranking,
  284.                 'list_ranking1'=>$list_ranking1,
  285.                 'list_ranking2'=>$list_ranking2,
  286.                 'list_ranking3'=>$list_ranking3,
  287.                 'rubrique_name'=>$rubrique_name,
  288.                 'rubrique_slug'=>$rubrique_slug,
  289.                 'lignes'=>$lignes,
  290.                 'photos'=>$photos,
  291.             ]),
  292.         ]);
  293.     }
  294.     /**
  295.      * @Route("/list_commcartesvisites/{slug_rub}",name="list_commcartesvisites")
  296.      */
  297.     public function list_commcartesvisites($slug_rub)
  298.     {
  299.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rub);
  300.         $id=!empty($rubrique) ? $rubrique->getId() : null;
  301.         $rubrique_name=!empty($rubrique) ?$rubrique->getRubrique() : null;
  302.         $rubrique_slug=!empty($rubrique) ? $rubrique->getSlugNom() :null;
  303.         $list_commcartesvisites $id != null $this->CommercesRepository->getCartVisitCommerces($id): '';
  304.         return new JsonResponse([
  305.             'html' => $this->renderView('Results_Search/template-parts/list_commcartesvisites.html.twig', [
  306.                 'list_commcartesvisites'=>$list_commcartesvisites,
  307.                 'rubrique_name'=>$rubrique_name,
  308.                 'rubrique_slug'=>$rubrique_slug,
  309.             ]),
  310.         ]);
  311.     }
  312.     /**
  313.      * @Route("/list_coloredComm/{slug_rub}",name="list_coloredComm")
  314.      */
  315.     public function list_coloredComm($slug_rub)
  316.     {
  317.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rub);
  318.         $id=!empty($rubrique) ? $rubrique->getId() : null;
  319.         $rubrique_name=!empty($rubrique) ?$rubrique->getRubrique() : null;
  320.         $rubrique_slug=!empty($rubrique) ? $rubrique->getSlugNom() :null;
  321.         $list_coloredComm $id != null $this->CommercesRepository->getColoredCommerces($id): '';
  322.         return new JsonResponse([
  323.             'html' => $this->renderView('Results_Search/template-parts/list_coloredComm.html.twig', [
  324.                 'list_coloredComm'=>$list_coloredComm,
  325.                 'rubrique_name'=>$rubrique_name,
  326.                 'rubrique_slug'=>$rubrique_slug,
  327.             ]),
  328.         ]);
  329.     }
  330.     /**
  331.      * @Route("/list_freeComm/{slug_rub}",name="list_freeComm")
  332.      */
  333.     public function list_freeComm($slug_rub)
  334.     {
  335.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rub);
  336.         $id=!empty($rubrique) ? $rubrique->getId() : null;
  337.         $list_freeComm $id != null $this->CommercesRepository->getFreeCommerces($id): '';
  338.         return new JsonResponse([
  339.             'html' => $this->renderView('Results_Search/template-parts/list_freeComm.html.twig', [
  340.                 'list_freeComm'=>$list_freeComm,
  341.             ]),
  342.         ]);
  343.     }
  344.     /**
  345.      * @Route("/rubrique/{slug_rubrique}/commune/{slug_commune}",name="rubrique_commune",requirements={ "slug_rubrique"="[^+]+", "slug_commune"="^(?!province.*$).*[^+]+" })
  346.      */
  347.     public function rubriqueCommune($slug_rubrique$slug_commune): Response
  348.     {
  349.         return $this->redirectToRoute('rub_comm_url',array('slug_rubrique'=>$slug_rubrique,'slug_commune'=>$slug_commune));
  350.     }
  351.     /**
  352.      * @Route("/rubrique+{slug_rubrique}+{slug_commune}.html",name="rub_comm_url", requirements={ "slug_rubrique"="[^+]+",  "rubrique_slug"="[^+]+" , "slug_commune"="^(?!province.*$).*[^+]+" })
  353.      */
  354.     public function rubcommurl($slug_rubrique$slug_commune): Response
  355.     {
  356.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  357.         $commune1$this->communeRepository->findOneBySlug($slug_commune);
  358.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  359.         $commune $commune1 $commune1 $commune2;
  360.         if ( $rubrique== null) {
  361.             return $this->redirectToRoute('text_rubrique_id_commune',array('text_rubrique'=>$slug_rubrique,'slug_commune'=>$slug_commune));
  362.         }
  363.         if ($commune == null and $rubrique== null) {
  364.             return new Response($this->twig->render('Results_Search/critere_not_found.html.twig',
  365.                 [
  366.                     'critere'=>$commune$slug_rubrique:$slug_commune,
  367.                     'champs_recherche' =>$commune'rubrique':'commune',
  368.                 ]));
  369.         }
  370.         else {
  371.             $commune_id = !empty($commune) ? $commune->getId() : null;
  372.             $commune_name = !empty($commune) ? $commune->getNom() : $slug_commune;
  373.             $commune_slug = !empty($commune) ? $commune->getSlugNom() : $slug_commune;
  374.             $province_name = !empty($commune) ? $commune->getIdProvince()->getNom() : null;
  375.             $province_obj = !empty($commune) ? $commune->getIdProvince() : null;
  376.             $province_url = !empty($commune) ? $commune->getIdProvince()->getUrl() : null;
  377.             $province_id = !empty($commune) ? $commune->getIdProvince()->getId() : null;
  378.             $commune_slug = !empty($commune1) ? $commune->getSlugNom() : $slug_commune;
  379.             $commune_nom = !empty($commune) ? $commune->getNom() : null;
  380.             $rubrique_id = !empty($rubrique) ? $rubrique->getId() : null;
  381.             $name = !empty($rubrique) ? $rubrique->getRubrique() : null;
  382.             $slug = !empty($rubrique) ? $rubrique->getSlugNom() : null;
  383.             // TOTAL RESULT
  384.             $id=!empty($rubrique) ? $rubrique->getId() : null;
  385.             $list_ranking $id != null $this->rankingRepository->findByRubriqueCommune($id,$commune_id) : '';
  386.             $list_ranking1 $id != null $this->rankingRepository->findByRubriqueCommuneAndLevel($id,$commune_id,1): '';
  387.             $list_ranking2 $id != null $this->rankingRepository->findByRubriqueCommuneAndLevel($id,$commune_id,2): '';
  388.             $list_ranking3 $id != null $this->rankingRepository->findByRubriqueCommuneAndLevel($id,$commune_id,3): '';
  389.             shuffle($list_ranking1);
  390.             shuffle($list_ranking2);
  391.             shuffle($list_ranking3);
  392.             $list_commcartesvisites $id != null $this->CommercesRepository->findCartVisitCommercesByRubriqueAndCommune($id,$commune_id): '';
  393.             $list_coloredComm $id != null $this->CommercesRepository->findColoredCommercesByRubriqueAndCommune($id,$commune_id): '';
  394.             $list_freeComm $id != null $this->CommercesRepository->findFreeCommercesByRubriqueAndCommune($id,$commune_id): '';
  395.             $total_resultcount($list_ranking) + count($list_freeComm) +count($list_commcartesvisites) + count($list_coloredComm);
  396.             // TOTAL RESULT
  397.             $meta_title $name " à " $commune_name " . Atout Commerces annuaire des commerçants et artisans en Wallonie | Atout-Commerces.be";
  398.             $meta_description "Liste complète des " $name " de la commune de " $commune_name " . Atout Commerces est un annuaire des commerçants, artisans, professions libérales, et entrepreneurs. 100.000 professionnels référencés. Retrouvez tous les " $name " en Wallonie.";
  399.             $lignes$this->rankingLignesRepository->findAll();
  400.             $photos$this->rankingPhotoRepository->findAll();
  401.             $descriptionseo=$this->descriptionRepository->findByRubriqueCommune($rubrique_id,$commune_id);
  402.             $linkFR"fr/rubrique+" $slug_rubrique "+"$slug_commune ".html";
  403.             $slugRubNL=!empty($rubrique) ?$rubrique->getRubriqueNL() : null;
  404.             $slugComNL=!empty($commune) ? $commune->getSlugNL() : null;
  405.             $linkNL="nl/rubrique+" $slugRubNL "+"$slugComNL ".html";
  406.             /**maillage*** */
  407.                     $communesMaillage = [];
  408.                     if ($province_obj && $rubrique_id) {
  409.                         $communesDeProvince $this->communeRepository->findBy(['idProvince' => $province_id]);
  410.                         foreach ($communesDeProvince as $communeProche) {
  411.                             $nbCommerces $this->CommercesRepository->countCommercesByRubriqueAndCommune($rubrique_id$communeProche->getId());
  412.                             if ($nbCommerces && $communeProche->getId() !== $commune_id) {
  413.                                 $communesMaillage[] = [
  414.                                     'nom' => $communeProche->getNom(),
  415.                                     'slugNom' => $communeProche->getSlugNom(),
  416.                                     'compteur' => $nbCommerces
  417.                                 ];
  418.                             }
  419.                         }
  420.                     }
  421.   usort($communesMaillage, function($a$b) {
  422.         return $b['compteur'] <=> $a['compteur'];
  423.     });
  424.             return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  425.                 [
  426.                     'list_ranking'=>$list_ranking,
  427.                     'list_ranking1'=>$list_ranking1,
  428.                     'list_ranking2'=>$list_ranking2,
  429.                     'list_ranking3'=>$list_ranking3,
  430.                     'list_commcartesvisites'=>$list_commcartesvisites,
  431.                     'list_coloredComm'=>$list_coloredComm,
  432.                     'list_freeComm'=>$list_freeComm,
  433.                     'lignes'=>$lignes,
  434.                     'photos'=>$photos,
  435.                     'ou'=>$commune_name,
  436.                     'idc'=>$commune_id,
  437.                     'idp'=>null,
  438.                     'rubrique_name'=>$name,
  439.                     'rubrique_slug'=>$slug,
  440.                     'name'=>$commune_name,
  441.                     'commune_nom'=>$commune_name,
  442.                     'province_obj'=>$province_obj,
  443.                     'slug'=>$commune_slug,
  444.                     'rubriqueobjet' =>$rubrique $rubrique null,
  445.                     'total_results' => $total_result,
  446.                     'descriptionseoo'=>$descriptionseo $descriptionseo null,
  447.                     'linkNL' => $linkNL,
  448.                     'linkFR' => $linkFR,
  449.                     'communes_maillage' => $communesMaillage,
  450.                     'province_nom' => $province_name,
  451.                 ]));
  452.         }
  453.     }
  454.     /**
  455.      * @Route("/rubrique_commune_stats/{slug_rubrique}/{slug_commune}",name="rubrique_commune_stats")
  456.      */
  457.     public function rubrique_commune_stats($slug_rubrique$slug_commune)
  458.     {
  459.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  460.         $commune1$this->communeRepository->findOneBySlug($slug_commune);
  461.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  462.         $commune $commune1 $commune1 $commune2;
  463.         $commune_id=!empty($commune) ? $commune->getId() : null;
  464.         $commune_name=!empty($commune1) ? $commune->getNom() : $slug_commune;
  465.         $province_name=!empty($commune) ? $commune->getIdProvince()->getNom() : null;
  466.         $rubrique_id=!empty($rubrique) ? $rubrique->getId():null;
  467.         $name=!empty($rubrique) ? $rubrique->getRubrique():null;
  468.         $slug=!empty($rubrique) ? $rubrique->getSlugNom():null;
  469.         $list_ranking =$commune_id !=null && $rubrique_id !=null $this->rankingRepository->findByRubriqueCommune($rubrique_id,$commune_id) :'';
  470.         $list_commcartesvisites =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findCartVisitCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  471.         $list_coloredComm =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findColoredCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  472.         $list_freeComm =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findFreeCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  473.         return new JsonResponse([
  474.             'html' => $this->renderView('Results_Search/template-parts/rubrique_stats.html.twig', [
  475.                 'list_ranking'=>$list_ranking,
  476.                 'list_commcartesvisites'=>$list_commcartesvisites,
  477.                 'list_coloredComm'=>$list_coloredComm,
  478.                 'list_freeComm'=>$list_freeComm,
  479.                 'rubrique_name'=>$name,
  480.                 'rubrique_slug'=>$slug,
  481.                 'ou'=>$commune_name,
  482.                 'idc'=>null,
  483.                 'idr'=>$rubrique_id,
  484.                 'province' => $province_name,
  485.                 'rubriqueobjet' =>$rubrique $rubrique null,
  486.             ]),
  487.         ]);
  488.     }
  489.     /**
  490.      * @Route("/list_ranking_rubrique_commune/{slug_rubrique}/{slug_commune}",name="list_ranking_rubrique_commune")
  491.      */
  492.     public function list_ranking_rubrique_commune($slug_rubrique$slug_commune)
  493.     {
  494.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  495.         $commune1$this->communeRepository->findOneBySlug($slug_commune);
  496.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  497.         $commune $commune1 $commune1 $commune2;
  498.         $commune_id=!empty($commune) ? $commune->getId() : null;
  499.         $rubrique_id=!empty($rubrique) ? $rubrique->getId():null;
  500.         $rubrique_name=!empty($rubrique) ? $rubrique->getRubrique():null;
  501.         $province_id=!empty($commune) ? $commune->getIdProvince()->getId():null;
  502.         $list_ranking =$commune_id !=null && $rubrique_id !=null $this->rankingRepository->findByRubriqueCommune($rubrique_id,$commune_id) :'';
  503.         $lignes$this->rankingLignesRepository->findAll();
  504.         $photos$this->rankingPhotoRepository->findAll();
  505.         return new JsonResponse([
  506.             'html' => $this->renderView('Results_Search/template-parts/list_ranking.html.twig', [
  507.                 'list_ranking'=>$list_ranking,
  508.                 'lignes'=>$lignes,
  509.                 'photos'=>$photos,
  510.                 'idC'=>$commune_id,
  511.                 'idP'=>$province_id,
  512.                 'rubrique_name'=>$rubrique_name,
  513.             ]),
  514.         ]);
  515.     }
  516.     /**
  517.      * @Route("/list_commcartesvisites_rubrique_commune/{slug_rubrique}/{slug_commune}",name="list_commcartesvisites_rubrique_commune")
  518.      */
  519.     public function list_commcartesvisites_rubrique_commune($slug_rubrique$slug_commune)
  520.     {
  521.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  522.         $commune1$this->communeRepository->findOneBySlug($slug_commune);
  523.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  524.         $commune $commune1 $commune1 $commune2;
  525.         $commune_id=!empty($commune) ? $commune->getId() : null;
  526.         $rubrique_id=!empty($rubrique) ? $rubrique->getId():null;
  527.         $list_commcartesvisites =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findCartVisitCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  528.         $rubrique_name=!empty($rubrique) ?$rubrique->getRubrique() : null;
  529.         return new JsonResponse([
  530.             'html' => $this->renderView('Results_Search/template-parts/list_commcartesvisites.html.twig', [
  531.                 'list_commcartesvisites'=>$list_commcartesvisites,
  532.                 'rubrique_name'=>$rubrique_name,
  533.             ]),
  534.         ]);
  535.     }
  536.     /**
  537.      * @Route("/list_coloredComm_rubrique_commune/{slug_rubrique}/{slug_commune}",name="list_coloredComm_rubrique_commune")
  538.      */
  539.     public function list_coloredComm_rubrique_commune($slug_rubrique$slug_commune)
  540.     {
  541.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  542.         $commune1$this->communeRepository->findOneBySlug($slug_commune);
  543.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  544.         $commune $commune1 $commune1 $commune2;
  545.         $commune_id=!empty($commune) ? $commune->getId() : null;
  546.         $rubrique_id=!empty($rubrique) ? $rubrique->getId():null;
  547.         $list_coloredComm =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findColoredCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  548.         return new JsonResponse([
  549.             'html' => $this->renderView('Results_Search/template-parts/list_coloredComm.html.twig', [
  550.                 'list_coloredComm'=>$list_coloredComm,
  551.             ]),
  552.         ]);
  553.     }
  554.     /**
  555.      * @Route("/list_freeComm/{slug_rubrique}/{slug_commune}",name="list_freeComm_rubrique_commune")
  556.      */
  557.     public function list_freeComm_rubrique_commune($slug_rubrique$slug_commune)
  558.     {
  559.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  560.         $commune1$this->communeRepository->findOneBySlug($slug_commune);
  561.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  562.         $commune $commune1 $commune1 $commune2;
  563.         $commune_id=!empty($commune) ? $commune->getId() : null;
  564.         $rubrique_id=!empty($rubrique) ? $rubrique->getId():null;
  565.         $list_freeComm =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findFreeCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  566.         return new JsonResponse([
  567.             'html' => $this->renderView('Results_Search/template-parts/list_freeComm.html.twig', [
  568.                 'list_freeComm'=>$list_freeComm,
  569.             ]),
  570.         ]);
  571.     }
  572.     /**
  573.      * @Route("/rubrique/{slug_rubrique}/province/{slug_province}",name="rubrique_province", requirements={ "slug_province"="[^+]+", "slug_rubrique"="[^+]+" })
  574.      */
  575.     public function rubriqueProvince($slug_rubrique$slug_province): Response
  576.     {
  577.         return $this->redirectToRoute('rub_prov_url',array('slug_rubrique'=>$slug_rubrique,'slug_province'=>$slug_province));
  578.     }
  579.     /**
  580.      * @Route("/rubrique+{slug_rubrique}+{slug_province}.html",name="rub_prov_url", requirements={ "slug_province"="[^+]+", "slug_province"="[^+]+" })
  581.      */
  582.     public function rubProvinceUrl($slug_rubrique$slug_province): Response
  583.     {
  584.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  585.         $province$this->provinceRepository->findOneBy(array('url'=>$slug_province));
  586.         if ( $rubrique == null) {
  587.             return $this->redirectToRoute('rub_text_prov_url',array('text_rubrique'=>$slug_rubrique,'slug_province'=>$slug_province));
  588.         }
  589.         if ($province == null and $rubrique== null) {
  590.             return new Response($this->twig->render('Results_Search/critere_not_found.html.twig',
  591.                 [
  592.                     'critere'=>$province$slug_rubrique:$slug_province,
  593.                     'champs_recherche' =>$province'rubrique':'province',
  594.                 ]));
  595.         } else {
  596.             $province_id = !empty($province) ? $province->getId() : null;
  597.             $province_name = !empty($province) ? $province->getNom() : null;
  598.             $province_slug = !empty($province) ? $province->getUrl() : null;
  599.             $rubrique_id = !empty($rubrique) ? $rubrique->getId() : null;
  600.             $name = !empty($rubrique) ? $rubrique->getRubrique() : null;
  601.             $slug = !empty($rubrique) ? $rubrique->getSlugNom() : null;
  602.             $list_ranking $province_id != null && $rubrique_id != null $this->rankingRepository->findByRubriqueProvince($rubrique_id$province_id) : '';
  603.             $list_commcartesvisites $province_id != null && $rubrique_id != null $this->CommercesRepository->findCartVisitCommercesByRubriqueAndProvince($rubrique_id$province_id) : '';
  604.             $list_coloredComm $province_id != null && $rubrique_id != null $this->CommercesRepository->findColoredCommercesByRubriqueAndProvince($rubrique_id$province_id) : '';
  605.             $list_freeComm $province_id != null && $rubrique_id != null $this->CommercesRepository->findFreeCommercesByRubriqueAndProvince($rubrique_id$province_id) : '';
  606.             $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  607.             $lignes $this->rankingLignesRepository->findAll();
  608.             $photos $this->rankingPhotoRepository->findAll();
  609.             // Get province communes for maillage
  610.             $provinceCommuneMapping $this->getProvinceCommuneMapping();
  611.             $province_communes_names = [];
  612.             foreach ($provinceCommuneMapping as $key => $communes) {
  613.                 if (strcasecmp($key$province_name) === 0) {
  614.                     $province_communes_names $communes;
  615.                     break;
  616.                 }
  617.             }
  618.             $province_communes_maillage = [];
  619.             if (!empty($province_communes_names) && $rubrique_id != null) {
  620.                 foreach ($province_communes_names as $commune_name) {
  621.                     $commune $this->communeRepository->findOneBy(['nom' => $commune_name]);
  622.                     
  623.                     if (!$commune) {
  624.                         continue;
  625.                     }
  626.                     $commune_id $commune->getId();
  627.                     
  628.                     // Get the count of commerces for this rubrique in this commune
  629.                     $count_ranking count($this->rankingRepository->findByRubriqueCommune($rubrique_id$commune_id));
  630.                     $count_cartes count($this->CommercesRepository->findCartVisitCommercesByRubriqueAndCommune($rubrique_id$commune_id));
  631.                     $count_colored count($this->CommercesRepository->findColoredCommercesByRubriqueAndCommune($rubrique_id$commune_id));
  632.                     $count_free count($this->CommercesRepository->findFreeCommercesByRubriqueAndCommune($rubrique_id$commune_id));
  633.                     
  634.                     $total_count $count_ranking $count_cartes $count_colored $count_free;
  635.                     
  636.                     $province_communes_maillage[] = [
  637.                         'nom' => $commune->getNom(),
  638.                         'slugNom' => $commune->getSlugNom(),
  639.                         'compteur' => $total_count
  640.                     ];
  641.                 }
  642.             }
  643.             $linkFR"fr/rubrique+" $slug_rubrique "+".$slug_province.".html";
  644.             $slugRubNL=!empty($rubrique) ?$rubrique->getRubriqueNL() : null;
  645.             $slugProvFR=!empty($province) ? $province->getProvNL() : null;
  646.             $linkNL"nl/rubrique+" $slugRubNL "+".$slugProvFR.".html";
  647.             return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  648.                 [
  649.                     'list_ranking' => $list_ranking,
  650.                     'list_commcartesvisites' => $list_commcartesvisites,
  651.                     'list_coloredComm' => $list_coloredComm,
  652.                     'list_freeComm' => $list_freeComm,
  653.                     'lignes' => $lignes,
  654.                     'photos' => $photos,
  655.                     'ou' => $province_name,
  656.                     'idc' => null,
  657.                     'idp' => $province_id,
  658.                     'rubrique_name' => $name,
  659.                     'rubrique_slug' => $slug,
  660.                     'name' => $province_name,
  661.                     'province' => $province_name,
  662.                     'slug' => $province_slug,
  663.                     'total_results' => $total_results,
  664.                     'commune_nom' => null,
  665.                     'province_obj' => $province,
  666.                     'rubriqueobjet' =>$rubrique $rubrique null,
  667.                     'linkNL' => $linkNL,
  668.                     'linkFR' => $linkFR,
  669.                     'province_communes_maillage' => $province_communes_maillage,
  670.                 ]));
  671.         }
  672.     }
  673.     /**
  674.      * @Route("/rubrique/{slug_rubrique}/code_postal/{code}",name="rubrique_code_postal", requirements={"token"=".+"})
  675.      */
  676.     public function rubriqueCodePostal($slug_rubrique$code): Response
  677.     {
  678.         $commune$this->communeRepository->findByCodePostal($code);
  679.         $commune_id=null;
  680.         $commune_name=null;
  681.         $commune_slugname=null;
  682.         $province_id=null;
  683.         foreach ( $commune as $c){
  684.             $commune_id=$c->getId();
  685.             $province_id=$c->getIdProvince();
  686.             $commune_name=$c->getNom();
  687.             $commune_slugname=$c->getSlugNom();
  688.         }
  689.         $rubrique$this->rubriqueRepository->findOneBySlug($slug_rubrique);
  690.         if ($commune == null or $rubrique == null){
  691.             return new Response($this->twig->render('bundles/TwigBundle/Exception/error404.html.twig'));
  692.         }else {
  693.             $rubrique_id = !empty($rubrique) ? $rubrique->getId() : null;
  694.             $name = !empty($rubrique) ? $rubrique->getRubrique() : null;
  695.             $list_ranking $commune_id != null && $rubrique_id != null $this->rankingRepository->findByRubriqueCommune($rubrique_id$commune_id) : '';
  696.             $list_commcartesvisites $commune_id != null && $rubrique_id != null $this->CommercesRepository->findCartVisitCommercesByRubriqueAndCommune($rubrique_id$commune_id) : '';
  697.             $list_coloredComm $commune_id != null && $rubrique_id != null $this->CommercesRepository->findColoredCommercesByRubriqueAndCommune($rubrique_id$commune_id) : '';
  698.             $list_freeComm $this->CommercesRepository->findFreeCommercesByRubriqueAndCommune($rubrique_id$commune_id);
  699.             $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  700.             $lignes $this->rankingLignesRepository->findAll();
  701.             $photos $this->rankingPhotoRepository->findAll();
  702.             $linkFR"fr/rubrique/" $slug_rubrique "/code_postal/"$code;
  703.             $linkNL=!empty($rubrique) ?$rubrique->getRubriqueNL() : null;
  704.             $linkNL"nl/rubrique/" $linkNL "/code_postal/"$code;
  705.             return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  706.                 [
  707.                     'list_ranking' => $list_ranking,
  708.                     'list_commcartesvisites' => $list_commcartesvisites,
  709.                     'list_coloredComm' => $list_coloredComm,
  710.                     'list_freeComm' => $list_freeComm,
  711.                     'lignes' => $lignes,
  712.                     'photos' => $photos,
  713.                     'ou' => $commune_name,
  714.                     'idc' => $commune_id,
  715.                     'idp' => $province_id,
  716.                     'rubrique_name' => $name,
  717.                     'name' => $commune_name,
  718.                     'commune_nom' => $commune_name,
  719.                     'total_results' => $total_results,
  720.                     'slug' => $commune_slugname,
  721.                     'rubriqueobjet' =>$rubrique $rubrique null,
  722.                     'linkNL' => $linkNL,
  723.                     'linkFR' => $linkFR,
  724.                 ]));
  725.         }
  726.     }
  727.     //text rubrique + id commune
  728.     /**
  729.      * @Route("/rubrique/{text_rubrique}+{slug_commune}.html",name="text_rubrique_id_commune", requirements={"token"=".+"})
  730.      */
  731.     public function textRubriqueIDCommune($text_rubrique,$slug_commune){
  732.         //var_dump("text",$text_rubrique); die();
  733.         $commune1$this->communeRepository->findOneBy(array('slugNom'=>$slug_commune));
  734.         $commune2$this->communeRepository->findOneByEntite1($slug_commune);
  735.         $commune $commune1 $commune1 $commune2;
  736.         $commune_id=!empty($commune) ? $commune->getId() : null;
  737.         $commune_name=!empty($commune) ? $commune->getNom() : null;
  738.         $commune_slug=!empty($commune) ? $commune->getSlugNom() : null;
  739.         $name=$text_rubrique;
  740.         $slug=$text_rubrique;
  741.         $list_ranking =$commune_id !=null  $this->rankingRepository->txtrubriqueIdCommune($text_rubrique,$commune_id) :'';
  742.         $list_commcartesvisites =$commune_id !=null  $this->CommercesRepository->findCartVisitCommercesByTxtRubriqueAndCommune($text_rubrique,$commune_id):'';
  743.         $list_coloredComm =$commune_id !=null $this->CommercesRepository->findColoredCommercesByTxtRubriqueAndCommune($text_rubrique,$commune_id):'';
  744.         $list_freeComm =$commune_id !=null  $this->CommercesRepository->findFreeCommercesByTxtRubriqueAndCommune($text_rubrique,$commune_id):'';
  745.         $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  746.         $lignes$this->rankingLignesRepository->findAll();
  747.         $photos$this->rankingPhotoRepository->findAll();
  748.         return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  749.             [
  750.                 'list_ranking'=>$list_ranking,
  751.                 'list_commcartesvisites'=>$list_commcartesvisites,
  752.                 'list_coloredComm'=>$list_coloredComm,
  753.                 'list_freeComm'=>$list_freeComm,
  754.                 'lignes'=>$lignes,
  755.                 'photos'=>$photos,
  756.                 'ou'=>$commune_name,
  757.                 'rubrique_name'=>$name,
  758.                 'idc'=>$commune_id,
  759.                 'rubrique_slug'=>$slug,
  760.                 'name'=>$commune_name,
  761.                 'slug'=>$commune_slug,
  762.                 'commune_nom' => null,
  763.                 'total_results' => $total_results,
  764.                 'idp' => null,
  765.             ]));
  766.     }
  767.     //text rubrique + id province
  768.     /**
  769.      * @Route("/rubrique/{text_rubrique}+{slug_province}",name="rub_text_prov_url", requirements={ "slug_province"="[^+]+", "slug_province"="[^+]+" })
  770.      */
  771.     public function textRubriqueIDProvince($text_rubrique$slug_province): Response
  772.     {
  773.         $province$this->provinceRepository->findOneBy(array('url'=>$slug_province));
  774.         $province_id=!empty($province)? $province->getId():null;
  775.         $province_name=!empty($province)? $province->getNom():null;
  776.         $province_slug=!empty($province)? $province->getUrl():null;
  777.         $commune_nom=null;
  778.         $ids_commune $this->communeRepository->findByIdProvince($province_id);
  779.         $ids=[];
  780.         foreach ($ids_commune as $c){
  781.             array_push($ids,$c->getId());
  782.         }
  783.         $list_ranking =$province_id !=null ?  $this->rankingRepository->findByTextRubriqueProvince($text_rubrique,$province_id) :'';
  784.         $list_commcartesvisites $province_id !=null  $this->CommercesRepository->findCartVisitCommercesByTextRubriqueAndProvince($text_rubrique,$province_id):'';
  785.         $list_coloredComm $province_id !=null  $this->CommercesRepository->findColoredCommercesByTextRubriqueAndProvince($text_rubrique,$province_id):'';
  786.         $list_freeComm $province_id !=null  $this->CommercesRepository->findFreeCommercesByTextRubriqueAndProvince($text_rubrique,$province_id):'';
  787.         $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  788.         $lignes$this->rankingLignesRepository->findAll();
  789.         $photos$this->rankingPhotoRepository->findAll();
  790.         // Get province communes for maillage
  791.         $provinceCommuneMapping $this->getProvinceCommuneMapping();
  792.         $province_communes_names = [];
  793.         foreach ($provinceCommuneMapping as $key => $communes) {
  794.             if (strcasecmp($key$province_name) === 0) {
  795.                 $province_communes_names $communes;
  796.                 break;
  797.             }
  798.         }
  799.         $province_communes_maillage = [];
  800.         if (!empty($province_communes_names)) {
  801.             foreach ($province_communes_names as $commune_name) {
  802.                 $commune $this->communeRepository->findOneBy(['nom' => $commune_name]);
  803.                 
  804.                 if (!$commune) {
  805.                     continue;
  806.                 }
  807.                 
  808.                 $commune_id $commune->getId();
  809.                 
  810.                 // Get the count of commerces for this text rubrique in this commune
  811.                 $count_ranking count($this->rankingRepository->txtrubriqueIdCommune($text_rubrique$commune_id));
  812.                 $count_cartes count($this->CommercesRepository->findCartVisitCommercesByTxtRubriqueAndCommune($text_rubrique$commune_id));
  813.                 $count_colored count($this->CommercesRepository->findColoredCommercesByTxtRubriqueAndCommune($text_rubrique$commune_id));
  814.                 $count_free count($this->CommercesRepository->findFreeCommercesByTxtRubriqueAndCommune($text_rubrique$commune_id));
  815.                 
  816.                 $total_count $count_ranking $count_cartes $count_colored $count_free;
  817.                 
  818.                 $province_communes_maillage[] = [
  819.                     'nom' => $commune->getNom(),
  820.                     'slugNom' => $commune->getSlugNom(),
  821.                     'compteur' => $total_count
  822.                 ];
  823.             }
  824.         }
  825.         $linkFR"fr/rubrique/" $text_rubrique "+".$slug_province;
  826.         $slugProvFR=!empty($province) ? $province->getProvNL() : null;
  827.         $linkNL"nl/rubrique/" $text_rubrique "+".$slugProvFR;
  828.         return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  829.             [
  830.                 'list_ranking'=>$list_ranking,
  831.                 'list_commcartesvisites'=>$list_commcartesvisites,
  832.                 'list_coloredComm'=>$list_coloredComm,
  833.                 'list_freeComm'=>$list_freeComm,
  834.                 'lignes'=>$lignes,
  835.                 'photos'=>$photos,
  836.                 'ou'=>$province_name,
  837.                 'idc'=>null,
  838.                 'idp'=>$province_id,
  839.                 'rubrique_name'=>$text_rubrique,
  840.                 'rubrique_slug'=>$text_rubrique,
  841.                 'name' => $province_name,
  842.                 'commune_nom' => null,
  843.                 'province_obj' => $province,
  844.                 'total_results' => $total_results,
  845.                 'slug' => $province_slug,
  846.                 'linkNL' => $linkNL,
  847.                 'linkFR' => $linkFR,
  848.                 'province_communes_maillage' => $province_communes_maillage,
  849.             ]));
  850.     }
  851.     /**
  852.      * @Route("/rubrique/{text}.html",name="rubrique_text", requirements={"slug"="[^+]+"})
  853.      */
  854.     public function textRubrique($text,Request $request): Response
  855.     {
  856.         $rubrique_name=$text;
  857.         $rubrique_slug=$text;
  858.         $communee $this->communeRepository->find30Communee();
  859.         $rubrique$this->rubriqueRepository->findOneBySlug($text);
  860.         $province_obj=null;
  861.          if (!$rubrique) {
  862.         // Rechercher par mot clé si non trouvé par slug
  863.         $rubrique $this->rubriqueRepository->findOneByMotCle($text);
  864.         if ($rubrique) {
  865.             // Rediriger vers la route avec le slug de la rubrique trouvée
  866.             return $this->redirectToRoute('rubrique_ranking', ['slug' => $rubrique->getSlugNom()]);
  867.         }
  868.     }
  869.         if($rubrique){
  870.             return $this->redirectToRoute('rubrique_ranking',array('slug'=>$text));
  871.         }else {
  872.             $list_ranking $this->rankingRepository->findByTextRubrique($text);
  873.             $list_ranking1 $this->rankingRepository->findByTextRubriqueAndLevel($text,1);
  874.             $list_ranking2 $this->rankingRepository->findByTextRubriqueAndLevel($text,2);
  875.             $list_ranking3 $this->rankingRepository->findByTextRubriqueAndLevel($text,3);
  876.             shuffle($list_ranking1);
  877.             shuffle($list_ranking2);
  878.             shuffle($list_ranking3);
  879.             // dd($list_ranking,$list_ranking1);
  880.             $list_commcartesvisites $this->CommercesRepository->getCartVisitCommercesByTextrub($text);
  881.             $list_coloredComm $this->CommercesRepository->getColoredCommercesByTextrub($text);
  882.             $list_freeComm $this->CommercesRepository->getFreeCommercesByTextrub($text);
  883.             $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  884.             // dd($list_freeComm,$list_commcartesvisites,$list_coloredComm,$list_ranking);
  885.             $lignes $this->rankingLignesRepository->findAll();
  886.             $photos $this->rankingPhotoRepository->findAll();
  887.             $meta_title $rubrique_name " Atout Commerces antextRubriqueCodePostalnuaire des commerçants et artisans en Wallonie | Atout-Commerces.be";
  888.             $meta_description "Liste complète des " $rubrique_name ". Atout Commerces est un annuaire des commerçants, artisans, professions libérales, et entrepreneurs. 100.000 professionnels référencés. Retrouvez tous les " $rubrique_name " en Wallonie.";
  889.             $linkNL"nl/rubrique/" $text .".html";
  890.             $linkFR="fr/rubrique/" $text .".html";
  891.             if ($request->query->get('l')=="get")
  892.             {
  893.                 return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  894.                     [
  895.                         'list_ranking' => $list_ranking,
  896.                         'list_ranking1' => $list_ranking1,
  897.                         'list_ranking2' => $list_ranking2,
  898.                         'list_ranking3' => $list_ranking3,
  899.                         'list_commcartesvisites' => $list_commcartesvisites,
  900.                         'list_coloredComm' => $list_coloredComm,
  901.                         'list_freeComm' => $list_freeComm,
  902.                         'lignes' => $lignes,
  903.                         'photos' => $photos,
  904.                         'idc' => null,
  905.                         'idp' => null,
  906.                         'rubrique_name' => $rubrique_name,
  907.                         'ou' => null,
  908.                         //'name'=>$rubrique_name,
  909.                         'rubrique_slug' => $rubrique_slug,
  910.                         'meta_title' => $meta_title,
  911.                         'meta_description' => $meta_description,
  912.                         'commune_nom' => null,
  913.                         'total_results' => $total_results,
  914.                         'province_obj' => $province_obj,
  915.                         'textCommercial'=>false,
  916.                         'communee'=>$communee,
  917.                         'noindex'=>count($list_ranking1) + count($list_ranking2) + count($list_ranking3)>=20,
  918.                         'linkNL' => $linkNL,
  919.                         'linkFR' => $linkFR,
  920.                         'noindex'=>count($list_ranking1) + count($list_ranking2) + count($list_ranking3)>=20
  921.                     ]));
  922.             }
  923.             if(count($list_ranking)<20 ){
  924.                 return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  925.                     [
  926.                         'list_ranking' => $list_ranking,
  927.                         'list_ranking1' => $list_ranking1,
  928.                         'list_ranking2' => $list_ranking2,
  929.                         'list_ranking3' => $list_ranking3,
  930.                         'list_commcartesvisites' => $list_commcartesvisites,
  931.                         'list_coloredComm' => $list_coloredComm,
  932.                         'list_freeComm' => $list_freeComm,
  933.                         'lignes' => $lignes,
  934.                         'photos' => $photos,
  935.                         'idc' => null,
  936.                         'idp' => null,
  937.                         'rubrique_name' => $rubrique_name,
  938.                         'ou' => null,
  939.                         'rubrique_slug' => $rubrique_slug,
  940.                         'meta_title' => $meta_title,
  941.                         'meta_description' => $meta_description,
  942.                         'commune_nom' => null,
  943.                         'total_results' => $total_results,
  944.                         'province_obj' => $province_obj,
  945.                         'textCommercial'=>  false,
  946.                         'communee'=>$communee,
  947.                         'linkNL' => $linkNL,
  948.                         'linkFR' => $linkFR,
  949.                         //'noindex'=>count($list_ranking)>=20
  950.                     ]));
  951.             }
  952.             if(count($list_ranking)>20 ){
  953.                 return new Response($this->twig->render('Results_Search/newRubrique.html.twig',
  954.                     [
  955.                         'list_ranking' => $list_ranking,
  956.                         'list_ranking1' => $list_ranking1,
  957.                         'list_ranking2' => $list_ranking2,
  958.                         'list_ranking3' => $list_ranking3,
  959.                         'lignes' => $lignes,
  960.                         'photos' => $photos,
  961.                         'idc' => null,
  962.                         'idp' => null,
  963.                         'rubrique_name' => $rubrique_name,
  964.                         'searchedText' => $text,
  965.                         'ou' => null,
  966.                         'rubrique_slug' => $rubrique_slug,
  967.                         'meta_title' => $meta_title,
  968.                         'meta_description' => $meta_description,
  969.                         'commune_nom' => null,
  970.                         'total_results' => $total_results,
  971.                         'province_obj' => $province_obj,
  972.                         'communee'=>$communee,
  973.                         'textCommercial'=>true,
  974.                         'linkNL' => $linkNL,
  975.                         'linkFR' => $linkFR,
  976.                         'textCommercial'=>true
  977.                     ]));
  978.             }
  979.             return new Response($this->twig->render('Results_Search/newRubrique.html.twig',
  980.                 [
  981.                     'list_ranking' => $list_ranking,
  982.                     'list_ranking1' => $list_ranking1,
  983.                     'list_ranking2' => $list_ranking2,
  984.                     'list_ranking3' => $list_ranking3,
  985.                     'lignes' => $lignes,
  986.                     'photos' => $photos,
  987.                     'idc' => null,
  988.                     'idp' => null,
  989.                     'rubrique_name' => $rubrique_name,
  990.                     'searchedText' => $text,
  991.                     'ou' => null,
  992.                     //'name'=>$rubrique_name,
  993.                     'rubrique_slug' => $rubrique_slug,
  994.                     'meta_title' => $meta_title,
  995.                     'meta_description' => $meta_description,
  996.                     'commune_nom' => null,
  997.                     'total_results' => $total_results,
  998.                     'province_obj' => $province_obj,
  999.                     'communee'=>$communee,
  1000.                     'textCommercial'=>false,
  1001.                     'linkNL' => $linkNL,
  1002.                     'linkFR' => $linkFR,
  1003.                     'textCommercial'=>false
  1004.                 ]));
  1005.         }
  1006.     }
  1007.     //text rubrique + code postal
  1008.     /**
  1009.      * @Route("/rubrique/{text_rubrique}/{codep}.html",name="text_rubrique_codep", requirements={"token"=".+"})
  1010.      */
  1011.     public function textRubriqueCodePostal($text_rubrique,$codep){
  1012.         $communeis_numeric($codep) ? $this->communeRepository->findByCodePostal($codep) :  $this->communeRepository->findByNomC1($codep);
  1013.         $commune$commune $commune:  $this->communeRepository->findOneBySlug($codep);
  1014.         $commune$commune $commune:  $this->communeRepository->findOneByEntite1($codep);
  1015.         $province_obj $commune null $this->provinceRepository->findOneBySlug($codep);
  1016.         if ( $province_obj) {
  1017.             return $this->redirectToRoute('rub_text_prov_url',array('text_rubrique'=>$text_rubrique,'slug_province'=>$codep));
  1018.         }
  1019.         $commune_id=  null;
  1020.         $commune_name=  null;
  1021.         $slugnull;
  1022.         if($commune != null) {
  1023.             $commune_id= !is_array($commune) ? $commune->getId() : null;
  1024.             $commune_name= !is_array($commune)  ? $commune->getNom() : null;
  1025.             $slug= !is_array($commune)  ? $commune->getSlugNom() : null;
  1026.             foreach ($commune as $c) {
  1027.                 $commune_id $c->getId();
  1028.                 $commune_name $c->getNom();
  1029.                 $slug $c->getSlugNom();
  1030.                 $province_obj $c->getIdProvince();
  1031.             }
  1032.         }
  1033.         $name=$text_rubrique;
  1034.         $list_ranking $commune_id !=null $this->rankingRepository->findByTxtRubriqueCommune($text_rubrique,$commune_id):'' ;
  1035.         $list_commcartesvisites =$commune_id !=null  $this->CommercesRepository->findCartVisitCommercesByTxtRubriqueAndCommune($text_rubrique,$commune_id):'';
  1036.         $list_coloredComm =$commune_id !=null  $this->CommercesRepository->findColoredCommercesByTxtRubriqueAndCommune($text_rubrique,$commune_id):'';
  1037.         $list_freeComm $this->CommercesRepository->findFreeCommercesByTxtRubriqueAndCommune($text_rubrique,$commune_id);
  1038.         $lignes$this->rankingLignesRepository->findAll();
  1039.         $photos$this->rankingPhotoRepository->findAll();
  1040.         $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  1041.         $meta_title $name." à ".$commune_name." . Atout Commerces annuaire des commerçants et artisans en Wallonie | Atout-Commerces.be";
  1042.         $meta_description "Liste complète des ".$name." de la commune de ".$commune_name." . Atout Commerces est un annuaire des commerçants, artisans, professions libérales, et entrepreneurs. 100.000 professionnels référencés. Retrouvez tous les ".$name." en Wallonie.";
  1043.         $linkNL"nl/rubrique/" $text_rubrique "/"$codep ".html";
  1044.         $linkFR="fr/rubrique/" $text_rubrique "/"$codep ".html";
  1045.         //  dd($text_rubrique,$codep,$commune_id,$commune_name,$slug,$province_obj);
  1046.         if (is_numeric($codep)  and $commune == null){
  1047.             return new Response($this->twig->render('Results_Search/critere_not_found.html.twig',
  1048.                 [
  1049.                     'critere'=>$codep,
  1050.                     'champs_recherche' => 'Code Postal'
  1051.                 ]));
  1052.         }else {
  1053.             return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  1054.                 [
  1055.                     'list_ranking' => $list_ranking,
  1056.                     'list_commcartesvisites' => $list_commcartesvisites,
  1057.                     'list_coloredComm' => $list_coloredComm,
  1058.                     'list_freeComm' => $list_freeComm,
  1059.                     'lignes' => $lignes,
  1060.                     'idc' => $commune_id,
  1061.                     'photos' => $photos,
  1062.                     'ou' => $commune_name,
  1063.                     'name' => $commune_name,
  1064.                     'idp' => null,
  1065.                     'rubrique_name' => $name,
  1066.                     'meta_title' => $meta_title,
  1067.                     'meta_description' => $meta_description,
  1068.                     'commune_nom' => $commune_name,
  1069.                     'slug' => $slug,
  1070.                     'province_obj' => $province_obj,
  1071.                     'total_results' => $total_results,
  1072.                     'linkNL' => $linkNL,
  1073.                     'linkFR' => $linkFR,
  1074.                     'total_results' => $total_results
  1075.                 ]));
  1076.         }
  1077.     }
  1078.     ///// id rubrique + text commune
  1079.     /**
  1080.      * @Route("/{id_rubrique}+{text_commune}.html",name="rub_text_comm")
  1081.      */
  1082.     public function findByIdrubStringcomm($id_rubrique$text_commune): Response
  1083.     {
  1084.         $rubrique$this->rubriqueRepository->findOneBySlug($id_rubrique);
  1085.         $commune$this->communeRepository->findByEntite($text_commune);
  1086.         // $commune= $commune ? $commune : $this->communeRepository->findByNomC($text_commune);
  1087.         $commune$commune $commune $this->communeRepository->findByNomC1($text_commune);
  1088.         $province_obj $commune null $this->provinceRepository->findOneBySlug($text_commune);
  1089.         if ( $province_obj) {
  1090.             $slug_province$province_obj->getUrl();
  1091.             $slug_rubrique$rubrique->getSlugNom();
  1092.             return $this->redirectToRoute('rubrique_province',array('slug_rubrique'=>$slug_rubrique,'slug_province'=>$slug_province));
  1093.         }
  1094.         $commune_id=null;
  1095.         $commune_name=null;
  1096.         $commune_slug=null;
  1097.         $province_obj=null;
  1098.         foreach ( $commune as $c){
  1099.             $commune_id=$c->getId();
  1100.             $commune_name=$c->getNom();
  1101.             $commune_slug=$c->getSlugNom();
  1102.             $province_obj=$c->getIdProvince();
  1103.         }
  1104.         $rubrique_id=!empty($rubrique) ? $rubrique->getId():null;
  1105.         $name=!empty($rubrique) ? $rubrique->getRubrique():null;
  1106.         $slug=!empty($rubrique) ? $rubrique->getSlugNom():null;
  1107.         $list_ranking =$commune_id !=null && $rubrique_id !=null $this->rankingRepository->findByRubriqueCommune($rubrique_id,$commune_id) :'';
  1108.         $list_commcartesvisites =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findCartVisitCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  1109.         $list_coloredComm =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findColoredCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  1110.         $list_freeComm =$commune_id !=null && $rubrique_id !=null $this->CommercesRepository->findFreeCommercesByRubriqueAndCommune($rubrique_id,$commune_id):'';
  1111.         $lignes$this->rankingLignesRepository->findAll();
  1112.         $photos$this->rankingPhotoRepository->findAll();
  1113.         $total_resultscount($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  1114.         $linkFR"fr/" $id_rubrique "+"$text_commune ".html";
  1115.         $slugRubNL=!empty($rubrique) ?$rubrique->getRubriqueNL() : null;
  1116.         $linkNL="nl/" $slugRubNL "+"$text_commune ".html";
  1117.         return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  1118.             [
  1119.                 'list_ranking'=>$list_ranking,
  1120.                 'list_commcartesvisites'=>$list_commcartesvisites,
  1121.                 'list_coloredComm'=>$list_coloredComm,
  1122.                 'list_freeComm'=>$list_freeComm,
  1123.                 'lignes'=>$lignes,
  1124.                 'photos'=>$photos,
  1125.                 'ou'=>$commune_name,
  1126.                 'idc'=>$commune_id,
  1127.                 'idp'=>null,
  1128.                 'rubrique_name'=>$name,
  1129.                 'rubrique_slug'=>$slug,
  1130.                 'name'=>$commune_name,
  1131.                 'commune_nom'=>$commune_name,
  1132.                 'province_obj'=>$province_obj,
  1133.                 'total_results'=>$total_results,
  1134.                 'slug'=>$commune_slug,
  1135.                 'linkNL' => $linkNL,
  1136.                 'linkFR' => $linkFR,
  1137.                 'slug'=>$commune_slug
  1138.             ]));
  1139.     }
  1140.     ///// text rubrique + text commune
  1141.     /**
  1142.      * @Route("/quoi+{text_rubrique}/ou+{text_commune}.html",name="str_rub_str_comm")
  1143.      */
  1144.     public function findByTextrubTextcomm($text_rubrique$text_commune): Response
  1145.     {
  1146.         $name=$text_rubrique;
  1147.         $slug=$text_rubrique;
  1148.         $commune$this->communeRepository->findByNomC1($text_commune);
  1149.         $commune$commune $commune $this->communeRepository->findOneByEntite($text_commune);
  1150.         $commune$commune $commune $this->communeRepository->findOneByEntite1($text_commune);
  1151.         $province_obj $commune null $this->provinceRepository->findOneBySlug($text_commune);
  1152.         $province_obj $province_obj null $this->provinceRepository->findOneNom($text_commune);
  1153.         if ( $province_obj) {
  1154.             if( is_array($province_obj)){
  1155.                 foreach ($province_obj as $p){
  1156.                     $slug_province $p->getUrl();
  1157.                 }
  1158.             }
  1159.             else{ $slug_province $province_obj->getUrl();}
  1160.             return $this->redirectToRoute('rub_text_prov_url',array('text_rubrique'=>$text_rubrique,'slug_province'=>$slug_province));
  1161.         }
  1162. //dd($commune,$province_obj);
  1163.         $commune_id=null;
  1164.         $commune_name=null;
  1165.         $commune_slug=null;
  1166.         foreach ( $commune as $c){
  1167.             $commune_id=$c->getId();
  1168.             $commune_name=$c->getNom();
  1169.             $commune_slug=$c->getSlugNom();
  1170.             $province_obj=$c->getIdProvince();
  1171.         }
  1172.         $list_ranking =$commune_id !=null  $this->rankingRepository->findByTextRubriqueTextComm($text_rubrique,$commune_name) :'';
  1173.         $list_commcartesvisites =$commune_id !=null$this->CommercesRepository->findCartVisitCommercesByTextRubriqueTextCommune($text_rubrique,$commune_id):'';
  1174.         $list_coloredComm =$commune_id !=null  $this->CommercesRepository->findColoredCommercesByTextRubriqueTextCommune($text_rubrique,$commune_id):'';
  1175.         $list_freeComm =$commune_id !=null  $this->CommercesRepository->findFreeCommercesByTextRubriqueTextCommune($text_rubrique,$commune_id):'';
  1176.         $lignes$this->rankingLignesRepository->findAll();
  1177.         $photos$this->rankingPhotoRepository->findAll();
  1178. //    $total_results= count($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  1179.         $countRis_array($list_ranking) ? count($list_ranking) : null;
  1180.         $countCCis_array($list_coloredComm) ? count($list_coloredComm) : null;
  1181.         $countCVis_array($list_commcartesvisites) ? count($list_commcartesvisites) : null;
  1182.         $countFR=  is_array($list_freeComm) ?  count($list_freeComm) : null;
  1183.         $total_results=$countR $countCC $countCV $countFR ;
  1184.         $meta_title $name." à ".$commune_name." . Atout Commerces annuaire des commerçants et artisans en Wallonie | Atout-Commerces.be";
  1185.         $meta_description "Liste complète des ".$name." de la commune de ".$commune_name." . Atout Commerces est un annuaire des commerçants, artisans, professions libérales, et entrepreneurs. 100.000 professionnels référencés. Retrouvez tous les ".$name." en Wallonie.";
  1186.         $linkNL"nl/quoi+" $text_rubrique "/ou+".$text_commune.".html";
  1187.         $linkFR"fr/quoi+" $text_rubrique "/ou+".$text_commune.".html";
  1188.         //   $total_results= count($list_ranking) + count($list_coloredComm) + count($list_commcartesvisites) + count($list_freeComm);
  1189.         $meta_title $name." à ".$commune_name." . Atout Commerces annuaire des commerçants et artisans en Wallonie | Atout-Commerces.be";
  1190.         $meta_description "Liste complète des ".$name." de la commune de ".$commune_name." . Atout Commerces est un annuaire des commerçants, artisans, professions libérales, et entrepreneurs. 100.000 professionnels référencés. Retrouvez tous les ".$name." en Wallonie.";
  1191.         return new Response($this->twig->render('Results_Search/rubrique.html.twig',
  1192.             [
  1193.                 'list_ranking'=>$list_ranking,
  1194.                 'list_commcartesvisites'=>$list_commcartesvisites,
  1195.                 'list_coloredComm'=>$list_coloredComm,
  1196.                 'list_freeComm'=>$list_freeComm,
  1197.                 'lignes'=>$lignes,
  1198.                 'photos'=>$photos,
  1199.                 'ou'=>$text_commune,
  1200.                 'idc'=>$commune_id,
  1201.                 'idp'=>null,
  1202.                 'rubrique_name'=>$name,
  1203.                 'rubrique_slug'=>$slug,
  1204.                 'name'=>$text_commune,
  1205.                 'commune_nom'=>$commune_name,
  1206.                 'province_obj'=>$province_obj,
  1207.                 'slug'=>$text_commune,
  1208.                 'meta_title' => $meta_title,
  1209.                 'meta_description' => $meta_description,
  1210.                 'total_results' => $total_results,
  1211.                 'linkNL' => $linkNL,
  1212.                 'linkFR' => $linkFR,
  1213.             ]));
  1214.     }
  1215.     //ranking details
  1216.     /**
  1217.      * @Route("/{nom_ranking}-{seo_ranking}_k_{id_ranking}.html",name="ranking_detail", defaults={"nom_ranking": "nom", "seo_ranking": "seo"} ,requirements={"token"=".+", "nom_ranking"="[^+]+", "seo_ranking"="[^+]+" })
  1218.      */
  1219.     public function  rankingDetails(Request $request,$id_ranking){
  1220.         $commune=$request->query->get("c");
  1221.         $province=$request->query->get("p");
  1222.         $rubriqueField=$request->query->get("r");
  1223.         $communeObj=null;
  1224.         $provinceObj=null;
  1225.         $communeSlug=null;
  1226.         $communeId=null;
  1227.         $provinceUrl=null;
  1228.         $provinceId=null;
  1229.         $rubriqueSlug=null;
  1230.         $rubriqueId=null;
  1231.         $rubriqueNom=null;
  1232.         if($commune != "null"){
  1233.             $idc=(int)$commune;
  1234.             $communeField=$idc$this->communeRepository->find($idc):null;
  1235.             $communeObj=$communeField;
  1236.             $communeSlug=$communeField?$communeField->getSlugNom():null;
  1237.             $communeId=$communeField?$communeField->getId():null;
  1238.         }
  1239.         // dd($province);
  1240.         if($province != "null"){
  1241.             $idp=(int)$province;
  1242.             $provinceField$idp?$this->provinceRepository->find($idp):null;
  1243.             $provinceObj=$provinceField;
  1244.             $provinceUrl=$provinceField?$provinceField->getUrl():null;
  1245.             $provinceId=$provinceField$provinceField->getId():null;
  1246.         }
  1247.         if($rubriqueField != "null"){
  1248.             $rub$this->rubriqueRepository->findOneBySlug($rubriqueField);
  1249.             $rub$rub$rub :$this->rubriqueRepository->findOneBy(array("rubrique"=>$rubriqueField));
  1250.             $rubriqueField$rub$rub null;
  1251.             $rubriqueSlug=$rub$rub->getSlugNom(): null;
  1252.             $rubriqueId=$rub?  $rub->getId(): null;
  1253.             $rubriqueNom=$rub?  $rub->getRubrique(): null;
  1254.         }
  1255.         $ranking $this->rankingRepository->find($id_ranking);
  1256.         if($ranking){
  1257.             // Vérification si 'afficher' est à 0
  1258.             if ($ranking->getAfficher() === 0) {
  1259.                 // Redirection vers la page 404 si 'afficher' est 0
  1260. //                return new Response($this->twig->render('Results_Search/critere_not_found.html.twig'), 404);
  1261.                 // Récupérer la première rubrique associée au ranking
  1262.                 $rubriques $ranking->getRubrique();
  1263.                 if (!empty($rubriques)) {
  1264.                     $rubrique $rubriques[0]; // On prend la première rubrique associée
  1265.                     $rubriqueSlug $rubrique->getSlugNom(); // Récupération du slug de la rubrique
  1266.                     // Redirection vers la page de la rubrique
  1267.                     return $this->redirectToRoute('rubrique_ranking', ['slug' => $rubriqueSlug]);
  1268.                 } else {
  1269.                     // Gérer le cas où il n'y a pas de rubrique associée
  1270.                     return new Response($this->twig->render('bundles/TwigBundle/Exception/error404.html.twig'));
  1271.                 }
  1272.             }
  1273.             $rubriques=$ranking->getRubrique();
  1274.             $rubrique_id=0;
  1275.             foreach ($rubriques as $r){
  1276.                 $rubrique_id$r->getId();
  1277.                 break;
  1278.             }
  1279.             $id$rubrique_id;
  1280.             $rubrique$this->rubriqueRepository->findByTextId($id);
  1281.             $lignes$this->rankingLignesRepository->findByRankingId($id_ranking);
  1282.             $photos$this->rankingPhotoRepository->findBy(array('ranking'=>$id_ranking));
  1283.             return new Response($this->twig->render('Results_Search/ranking_details.html.twig',
  1284.                 [
  1285.                     'ranking'=>!empty($ranking) ? $ranking'',
  1286.                     'lignes'=>$lignes,
  1287.                     'photos'=>$photos,
  1288.                     'commune'=>!empty($nomC)? $nomC '',
  1289.                     'idc'=>!empty($idC)? $idC '',
  1290.                     'slugc'=>!empty($slugC)? $slugC '',
  1291.                     'province_nom'=>!empty($nomp)? $nomp '',
  1292.                     'province_slug'=>!empty($slugp)? $slugp '',
  1293.                     'province_id'=>!empty($idP)? $idP null,
  1294.                     'categorie'=>!empty($rubrique)? $rubrique null,
  1295.                     'rubriqueField'=>$rubriqueField,
  1296.                     'communeObj'=>$communeObj,
  1297.                     'provinceObj'=>$provinceObj,
  1298.                     'communeSlug'=>$communeSlug,
  1299.                     'communeId'=>$communeId,
  1300.                     'provinceUrl'=>$provinceUrl,
  1301.                     'rubrique_Slug'=>$rubriqueSlug,
  1302.                     'rubrique_Nom'=>$rubriqueNom,
  1303.                     'rubrique_id'=>$rubriqueId,
  1304.                     'provinceId'=>$provinceId
  1305.                 ]));
  1306.         }else{
  1307.             return new Response($this->twig->render('bundles/TwigBundle/Exception/error404.html.twig'));
  1308.         }
  1309.     }
  1310.     /**
  1311.      * @Route("/ranking_detail.html",name="ranking_bo",requirements={"token"=".+"})
  1312.      * @IsGranted("ROLE_ADMIN")
  1313.      */
  1314.     public function  rankingDetailsFromBO(Request $request){
  1315.         $id_ranking$request->attributes->get("0");
  1316.         $ranking $this->rankingRepository->find($id_ranking);
  1317.         $commune=$this->communeRepository->findByIdRanking($id_ranking);
  1318.         //
  1319.         $rubriques=$ranking->getRubrique();
  1320.         $rubrique_id=0;
  1321.         foreach ($rubriques as $r){
  1322.             $rubrique_id$r->getId();
  1323.             break;
  1324.         }
  1325.         $id$rubrique_id;
  1326.         $rubrique$this->rubriqueRepository->findByTextId($id);
  1327.         $lignes$this->rankingLignesRepository->findByRankingId($id_ranking);
  1328.         $photos$this->rankingPhotoRepository->findBy(array('ranking'=>$id_ranking));
  1329.         $nomC='';
  1330.         $nomp='';
  1331.         foreach ($commune as $c){
  1332.             $nomC $c->getNom();
  1333.             $slugC $c->getSlugNom();
  1334.             $idC $c->getId();
  1335.             $nomp $c->getIdProvince()->getNom();
  1336.             $slugp $c->getIdProvince()->getUrl();
  1337.             $idP$c->getIdProvince()->getId();
  1338.         }
  1339.         return new Response($this->twig->render('Admin/ranking_details.html.twig',
  1340.             [
  1341.                 'ranking'=>!empty($ranking) ? $ranking'',
  1342.                 'lignes'=>$lignes,
  1343.                 'photos'=>$photos,
  1344.                 'commune'=>!empty($nomC)? $nomC '',
  1345.                 'idc'=>!empty($idC)? $idC '',
  1346.                 'slugc'=>!empty($slugC)? $slugC '',
  1347.                 'province_nom'=>!empty($nomp)? $nomp '',
  1348.                 'province_slug'=>!empty($slugp)? $slugp '',
  1349.                 'province_id'=>!empty($idP)? $idP null,
  1350.                 'categorie'=>!empty($rubrique)? $rubrique null
  1351.             ]));
  1352.     }
  1353.     public function getMaxRubCom($id_comm): Response
  1354. {
  1355.     $id = (int) $id_comm;
  1356.     if ($id <= 0) {
  1357.         return new Response(
  1358.             $this->twig->render('Results_Search/Counting/commercesRubByCom.html.twig', [
  1359.                 'commerces' => [],
  1360.                 'commune' => null,
  1361.             ])
  1362.         );
  1363.     }
  1364.     $commune $this->communeRepository->find($id);
  1365.     if (!$commune) {
  1366.         return new Response(
  1367.             $this->twig->render('Results_Search/Counting/commercesRubByCom.html.twig', [
  1368.                 'commerces' => [],
  1369.                 'commune' => null,
  1370.             ])
  1371.         );
  1372.     }
  1373.     $commerces $this->CommercesRepository->countCommByRubCom($id);
  1374.     return new Response(
  1375.         $this->twig->render('Results_Search/Counting/commercesRubByCom.html.twig', [
  1376.             'commerces' => $commerces,
  1377.             'commune' => $commune,
  1378.         ])
  1379.     );
  1380. }
  1381.     private function getProvinceCommuneMapping(): array
  1382.     {
  1383.         return [
  1384.         'Province du Brabant-Wallon' => [
  1385.                 "Braine l'Alleud & entités",
  1386.                 "Chaumont-Gistoux & entités",
  1387.                 "Genappe & entités",
  1388.                 "Grez-Doiceau, Beauvechain",
  1389.                 "Jodoigne, Incourt & entités",
  1390.                 "Lasne, La Hulpe & entités",
  1391.                 "Nivelles & entités",
  1392.                 "Orp-Jauche, Hélécine & entités",
  1393.                 "Ottignies, Louvain-la-Neuve",
  1394.                 "Perwez, Ramillies & entités",
  1395.                 "Rixensart & entités",
  1396.                 "Villers-la-ville, Court-Saint-Etienne & entités",
  1397.                 "Walhain, Chastre, Mont-Saint-Guibert & entités",
  1398.                 "Waterloo",
  1399.                 "Wavre & entités"
  1400.             ],
  1401.             'Province du Hainaut' => [
  1402.                 "Ath & entités",
  1403.                 "Beaumont, Cerfontaine, Froidchapelle, Sivry-Rance & entités",
  1404.                 "Beloeil & entités",
  1405.                 "Binche & entités",
  1406.                 "Braine-le-Comte & entités",
  1407.                 "Celles, Mont-de-l'Enclus, Frasnes-lez-Anvaing & entités",
  1408.                 "Charleroi (Ville)",
  1409.                 "Châtelet & entités",
  1410.                 "Chièvres, Brugelette & entités",
  1411.                 "Courcelles & entités",
  1412.                 "Ecaussinnes, Seneffe, Le Roeulx & entités",
  1413.                 "Erquelinnes, Merbes-le-Château",
  1414.                 "Estaimpuis, Pecq & entités",
  1415.                 "Fleurus & entités",
  1416.                 "Frameries, Quévy & entités",
  1417.                 "Gerpinnes & entités",
  1418.                 "La Louvière (centre), Haine-St-Paul, Haine-St-Pierre",
  1419.                 "Leuze-en-Hainaut & entités",
  1420.                 "Manage & entités",
  1421.                 "Mons (centre-ville)",
  1422.                 "Entités Mons (sauf Ghlin & Jemappes)",
  1423.                 "Peruwelz & entités",
  1424.                 "Pont-à-Celles, Les Bons Villers & entités",
  1425.                 "Saint-Ghislain & entités",
  1426.                 "Soignies & entités",
  1427.                 "Tournai (centre-ville)"
  1428.             ],
  1429.             'Province de Liège' => [
  1430.                 "Ans & entités""Anthisnes, Ferrières, Hamoir, Comblain-au-Pont & entités""Aubel, Herve, Thimister-Clermont et entités",
  1431.                 "Awans, Crisnée, Oreye & entités""Bassenge & entités""Beyne-Heusay, Fléron & entités""Chaudfontaine & entités, Chênée",
  1432.                 "Esneux, Tilff & entités, Boncelles""Hannut, Lincent & entités""Héron, Wanze & entités""Herstal (Centre), Vottem",
  1433.                 "Herve & entités""Huy, Amay, Villers-le-Bouillet & entités""Limbourg, Baelen & entités",  "Malmedy, Stavelot & entités",
  1434.                 "Neupré, Nandrin & entités""Ouffet, Tinlot, Clavier, Modave & entités",  "Oupeye, Vivegnis, Haccourt",
  1435.                 "Pepinster, Theux & entités""Soumagne, Olne & entités",  "Spa, Jalhay, Sart-lez-Spa",
  1436.                 "Sprimont, Aywaille & entités""Verviers (centre-ville), Heusy""Visé, Dalhem, Blegny & entités""Waremme, Berloz, Remicourt & entités",
  1437.                 "Wasseiges, Burdinne, Braives & entités""Welkenraedt, Henri-Chapelle"
  1438.             ],
  1439.             'Province du Luxembourg' => [
  1440.                 "Arlon & entités",
  1441.                 "Aubange & entités",
  1442.                 "Bastogne, Houffalize",
  1443.                 "Bertrix, Chiny, Herbeumont & entités",
  1444.                 "Bouillon, Paliseul & entités",
  1445.                 "Habay, Etalle & entités",
  1446.                 "Libramont, Saint-Hubert & entités",
  1447.                 "Marche-en-Famenne, La Roche-en-Ardenne, Rendeux, Hotton & entités",
  1448.                 "Martelange, Attert, Léglise, Fauvillers & entités",
  1449.                 "Messancy, Musson, Saint-Léger & entités",
  1450.                 "Vielsalm, Gouvy, Manhay, Lierneux & entités",
  1451.                 "Virton, Meix-devant-Virton, Rouvroy & entités"
  1452.             ],
  1453.             'Province de Namur' => [
  1454.                 "Andenne & entités",
  1455.                 "Beauraing, Wellin, Tellin, Daverdisse & entités",
  1456.                 "Couvin, Chimay, Momignies & entités",
  1457.                 "Ciney & entités",
  1458.                 "Dinant, Houyet & entités",
  1459.                 "Eghezée & entités",
  1460.                 "Fernelmont & entités",
  1461.                 "Floreffe & entités",
  1462.                 "Fosses-la-Ville & entités",
  1463.                 "Gedinne, Bièvre, Vresse-sur-Semois & entités",
  1464.                 "Gembloux & entités",
  1465.                 "Hamois, Assesse & entités",
  1466.                 "Jambes & Saint-Servais",
  1467.                 "Jemeppe-sur-Sambre & entités",
  1468.                 "La Bruyère & entités",
  1469.                 "Mettet, Florennes & entités",
  1470.                 "Ohey, Gesves & entités",
  1471.                 "Philippeville, Hastière, Doische, Viroinval & entités",
  1472.                 "Profondeville & entités",
  1473.                 "Rochefort & entités",
  1474.                 "Sambreville & entités",
  1475.                 "Sombreffe",
  1476.                 "Somme-Leuze, Havelange & entités",
  1477.                 "Walcourt & entités"
  1478.             ]
  1479.         ];
  1480.     }
  1481. }