src/Controller/MedecinController.php line 96

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Agencies;
  4. use App\Entity\AgencyDoctors;
  5. use App\Entity\Categories;
  6. use App\Entity\CenterZipcode;
  7. use App\Entity\Centers;
  8. use App\Entity\Cities;
  9. use App\Entity\Degrees;
  10. use App\Entity\DoctorDegrees;
  11. use App\Entity\DoctorPractices;
  12. use App\Entity\Doctors;
  13. use App\Entity\Geocode;
  14. use App\Entity\Hospitals;
  15. use App\Entity\Image;
  16. use App\Entity\Lookup;
  17. use App\Entity\Maps;
  18. use App\Entity\NewsDoctors;
  19. use App\Entity\Practices;
  20. use App\Entity\ServiceDoctors;
  21. use App\Entity\Services;
  22. use App\Entity\Zipcode;
  23. use App\Repository\DoctorPracticesRepository;
  24. use App\Repository\DoctorsRepository;
  25. use App\Repository\ServiceDoctorsRepository;
  26. use Knp\Component\Pager\PaginatorInterface;
  27. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  28. use Symfony\Component\HttpFoundation\Request;
  29. use Symfony\Component\HttpFoundation\Response;
  30. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  31. use Symfony\Component\Routing\Annotation\Route;
  32. use PhpOffice\PhpSpreadsheet\IOFactory;
  33. use Cocur\Slugify\Slugify;
  34. use Doctrine\ORM\EntityManagerInterface;
  35. use Dom\Entity;
  36. class MedecinController extends AbstractController
  37. {
  38.     /**
  39.      * @Route("/medecin-ORL-phoniatre/{id}", name="redirect_id_medecin", requirements={"id"="\d+"})
  40.      */
  41.     public function redirectIdOnly($id)
  42.     {
  43.         $doctor $this->getDoctrine()->getRepository(Doctors::class)->findOneBy(['id' => $id'visible' => 1]);
  44.         if ($doctor) {
  45.             $slug $this->slugify->slugify($doctor->getFirstName() . '-' $doctor->getName());
  46.             $url $this->router->generate(
  47.                 'page_single_medecin_alone',
  48.                 array('nomMedecin' => $slug'idMedecin' => $id)
  49.             );
  50.         } else {
  51.             $url $this->router->generate(
  52.                 'liste_medecin'
  53.             );
  54.         }
  55.         return $this->redirect($url301);
  56.     }
  57.     /**
  58.      * @Route("/medecin-ORL-phoniatre/page/{page}", name="redirect_page_medecins")
  59.      */
  60.     public function redirectPage($page null)
  61.     {
  62.         if ($page) {
  63.             $url $this->router->generate(
  64.                 'liste_medecin'
  65.             );
  66.         }
  67.         return $this->redirect($url301);
  68.     }
  69.     /**
  70.      * @Route("/medecin-ORL-phoniatre", name="liste_medecin")
  71.      */
  72.     public function renderDefault(): Response
  73.     {
  74.         $this->setJsonIntoTemplate('list');
  75.         $this->setTemplateParameters(array('title_seo' => "Médecins ORL et Phoniatres : Trouvez un médecin ORL près de chez vous"));
  76.         $data =  $this->JsonProvider->getJson('seo_text_medecins_orl');
  77.         $this->setTemplateParameters(array('seo_text' => json_decode($data)));
  78.         $this->setInternalLinkage('medecinListe');
  79.         return $this->renderTemplate('pages/annuaire_search_ORL.twig');
  80.     }
  81.     /**
  82.      * @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}.html", name="results_medecin_audio_by_city", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
  83.      * @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}/filtre-resultats/phoniatres-{isPhoniatre}.html", name="results_medecin_audio_by_city_filter_phoniatre", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
  84.      * @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}/filtre-resultats/exercice-{exercice}.html", name="results_medecin_audio_by_city_filter_exercice", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
  85.      * @Route("/medecin-ORL-phoniatre-{zipcode}-{ville}/filtre-resultats/{idspecialite}-{specialite}.html", name="results_medecin_audio_by_city_filter_specialite", requirements={"zipcode"="\d{5}"}, defaults={"page" = 1})
  86.      * @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}.html", name="results_medecin_by_departement", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
  87.      * @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}/filtre-resultats/phoniatres-{isPhoniatre}.html", name="results_medecin_by_departement_filter_phoniatre", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
  88.      * @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}/filtre-resultats/exercice-{exercice}.html", name="results_medecin_by_departement_filter_exercice", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
  89.      * @Route("/medecin-ORL-phoniatre-{departementCode}-{departementTexte}/filtre-resultats/{idspecialite}-{specialite}.html", name="results_medecin_by_departement_filter_specialite", requirements={"departementCode"="[0-9]{1,2}[0-9A-B]{1}"}, defaults={"page" = 1})
  90.      * 
  91.      */
  92.     public function renderList($zipcode null$ville null$departementCode null$departementTexte null$isPhoniatre null$exercice null$idspecialite null$specialite nullRequest $requestPaginatorInterface $paginator): Response
  93.     {
  94.         $title_seo "Médecins ORL - Phoniatres";
  95.         $doctors_title_seo $doctors_description_seo null;
  96.         if ($idspecialite) {
  97.             $diplomeCheck $this->getDoctrine()->getRepository(Degrees::class)->findOneBy(array('id' => $idspecialite));
  98.             if (!$diplomeCheck) {
  99.                 if ($zipcode) {
  100.                     return $this->redirectProvider->redirect301('results_medecin_audio_by_city', array('zipcode' => $zipcode'ville' => $ville));
  101.                 } else if ($departementCode) {
  102.                     return $this->redirectProvider->redirect301('results_medecin_by_departement', array('departementCode' => $departementCode'departementTexte' => $departementTexte));
  103.                 }
  104.             } else if ($this->slugify->slugify($diplomeCheck->getName()) != $specialite) {
  105.                 $slugCheck $this->slugify->slugify($diplomeCheck->getName());
  106.                 if ($zipcode) {
  107.                     return $this->redirectProvider->redirect301('results_medecin_audio_by_city_filter_specialite', array('zipcode' => $zipcode'ville' => $ville'idspecialite' => $idspecialite'specialite' => $slugCheck));
  108.                 } else if ($departementCode) {
  109.                     return $this->redirectProvider->redirect301('results_medecin_by_departement_filter_specialite', array('departementCode' => $departementCode'departementTexte' => $departementTexte'idspecialite' => $idspecialite'specialite' => $slugCheck));
  110.                 }
  111.             }
  112.         }
  113.         $result = [];
  114.         $searchtype = [];
  115.         $doctorsID = [];
  116.         $localisationId $lng $lat $canonical_url null;
  117.         $doctors = array();
  118.         // SI RECHERCHE PAR VILLE
  119.         if ($zipcode) {
  120.             /********** Description seo ***************/
  121.             $description_seo "ORL à " $this->dataProvider->wordUpperCaseFirstLetter($ville) . " (" $zipcode ") : Trouvez un médecin ORL ou phoniatre proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
  122.             // LOCALISATION           
  123.             $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
  124.                 'zipcode' => $zipcode,
  125.                 'city' => strtoupper($ville)
  126.             ));
  127.             if (!$localisation) {
  128.                 $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
  129.                     'zipcode' => $zipcode,
  130.                     'city' => strtoupper(str_replace('-'' '$ville))
  131.                 ));
  132.             }
  133.             if (!$localisation) {
  134.                 $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findByZipCodeAndCityLike($zipcode$ville);
  135.             }
  136.             if (!$localisation) {
  137.                 $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['zipcode' => $zipcode]);
  138.             }
  139.             if (!$localisation) {
  140.                 throw new NotFoundHttpException();
  141.             }
  142.             if ($ville != $this->slugify->slugify($localisation->getCity())) {
  143.                 return $this->redirectProvider->redirect301('results_medecin_audio_by_city', array('ville' => $this->slugify->slugify($localisation->getCity()), 'zipcode' => $zipcode));
  144.             }
  145.             $cities $localisation->getCities();
  146.             if (!$cities) {
  147.                 $cities $this->geoProvider->addCities($ville$zipcode$localisation);
  148.             }
  149.             // DEPARTEMENT ET COORDONNEES
  150.             if (!empty($localisation->getCities())) {
  151.                 $departementTexte $localisation->getCities()->getDeptTxt();
  152.                 $depcode $localisation->getCities()->getDeptcode();
  153.                 $localisationId $localisation->getCities()->getId();
  154.                 $lat $localisation->getCities()->getLat();
  155.                 $lng $localisation->getCities()->getLng();
  156.             } else {
  157.                 $dep $localisation->getDepartment();
  158.                 $departementTexte substr($dep7);
  159.                 $depcode substr($dep02);
  160.             }
  161.             // PREFOOTER 
  162.             $searchtype['departementCode'] = $depcode;
  163.             $searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
  164.             // BREADCRUMB
  165.             $this->breadDatas['type'] = 'city';
  166.             $this->breadDatas['final'] = $localisation->getCity() . " (" $zipcode ")";
  167.             $this->breadDatas['final_url'] = $this->router->generate(
  168.                 'results_medecin_audio_by_city',
  169.                 array('zipcode' => $zipcode'ville' => $this->slugify->slugify($ville))
  170.             );
  171.             $this->breadDatas['departementTxt'] = $departementTexte;
  172.             $this->breadDatas['departementCode'] = $depcode;
  173.             $arrondissement false;
  174.             if ($ville == "paris" || $ville == "marseille" || $ville == "lyon") {
  175.                 $arrondissement " " $this->dataProvider->getArrondissement($zipcode);
  176.                 if ($ville != "paris")
  177.                     $this->breadDatas['villeArrondissement'] = $ville;
  178.             }
  179.             $title_seo "ORL " $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . $arrondissement " (" $zipcode ") - Phoniatre : Prenez RDV en ligne";
  180.             // TITRE DE RECHERCHE
  181.             $search_location $ville;
  182.             // Recherche basée sur le zipcode des adresses des cabinets et des hopitaux
  183.             $doctors $this->getDoctrine()->getRepository(Doctors::class)->findByLocalisation($localisation->getId());
  184.             foreach ($doctors as $doctor) {
  185.                 $doctor->zip $zipcode;
  186.                 $doctor->city $ville;
  187.             }
  188.             $total_results count($doctors);
  189.             $limit 30 $total_results;
  190.             if ($total_results 30) {
  191.                 $doctors_proximite = [];
  192.                 // ------- Récupération coordonnées de la ville courante
  193.                 $lat $localisation->getCities()->getLat();
  194.                 $lng $localisation->getCities()->getLng();
  195.                 $idLoc $localisation->getCities()->getId();
  196.                 $cities_proximite $this->getDoctrine()->getRepository(Zipcode::class)->findCitiesByProximite($lat$lng$idLoc);
  197.                 foreach ($cities_proximite as $city) {
  198.                     if ($zip_pro $this->getDoctrine()->getRepository(Zipcode::class)->find($city[0]->getId())) {
  199.                         $zip_pro_id $zip_pro->getId();
  200.                         if ($total_results 30) {
  201.                             $doctors_proximite $this->getDoctrine()->getRepository(Doctors::class)->findByLocalisation($city[0]->getId());
  202.                             foreach ($doctors_proximite as $doctor_proximite) {
  203.                                 if (!in_array($doctor_proximite$doctors) && $total_results 30) {
  204.                                     $doctor_proximite->zip $zip_pro->getZipcode();
  205.                                     $doctor_proximite->city $zip_pro->getCity();
  206.                                     array_push($doctors$doctor_proximite);
  207.                                     $total_results count($doctors);
  208.                                     $limit 30 $total_results;
  209.                                 }
  210.                             }
  211.                         }
  212.                     }
  213.                 }
  214.             }
  215.             $datasFilters = array('ville' => $ville'zipcode' => $zipcode);
  216.             // Description seo //
  217.             if ($localisation) {
  218.                 $doctors_title_seo $localisation->getDoctorsTitleSeo();
  219.                 $doctors_description_seo html_entity_decode($localisation->getDoctorsDescriptionSeo(), ENT_QUOTES);
  220.             }
  221.             $canonical_url $this->router->generate('results_medecin_audio_by_city', array('zipcode' => $zipcode'ville' => $this->slugify->slugify($ville)));
  222.             $centers_url $this->router->generate('results_centres_audio_by_city', array('zipcode' => $zipcode'ville' => $this->slugify->slugify($ville)));
  223.             //$audio_url = $this->router->generate('results_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
  224.             $ortho_url $this->router->generate('results_ortho_audio_by_city', array('zipcode' => $zipcode'ville' => $this->slugify->slugify($ville)));
  225.             //$searchtype['exceptZipCode'] = $zipcode;
  226.             $this->setTemplateParameters(array('zipcode' => $zipcode));
  227.             $this->setTemplateParameters(array('ville' => $ville));
  228.         }
  229.         // SI RECHERCHE PAR DEPARTEMENT
  230.         elseif ($departementCode) {
  231.             $depcode $departementCode;
  232.             /************ Description seo ***************/
  233.             $description_seo "ORL " $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" $departementCode ") : Trouvez un médecin ORL ou phoniatre proche de chez vous, consultez ses coordonnées et prenez rendez-vous avec l'Annuaire de l'Audition.";
  234.             // PREFOOTER 
  235.             $searchtype['departementCode'] = $departementCode;
  236.             $searchtype['departementTexte'] = $this->slugify->slugify($departementTexte);
  237.             $localisation $this->getDoctrine()->getRepository(Cities::class)->findOneBy(array('deptCode' => $departementCode));
  238.             $checkDept $this->slugify->slugify($localisation->getDeptTxt());
  239.             if ($checkDept != $departementTexte && ($departementTexte != 'lyon' && $departementTexte != 'paris' && $departementTexte != 'marseille')) {
  240.                 return $this->redirectProvider->redirect301('results_medecin_by_departement', array('departementCode' => $departementCode'departementTexte' => $checkDept));
  241.             }
  242.             $ville $localisation->getVille();
  243.             $zipcode $localisation->getZipCode();
  244.             // DEPARTEMENT ET COORDONNEES
  245.             $localisationId $localisation->getId();
  246.             $lat $localisation->getLat();
  247.             $lng $localisation->getLng();
  248.             // BREADCRUMB
  249.             $this->breadDatas['type'] = 'dept';
  250.             $this->breadDatas['final'] = $localisation->getDeptTxt() . " (" $departementCode ")";
  251.             $this->breadDatas['final_url'] = $this->router->generate(
  252.                 'results_medecin_by_departement',
  253.                 array('departementCode' => $departementCode'departementTexte' => $this->slugify->slugify($departementTexte))
  254.             );
  255.             $title_seo "ORL " $this->dataProvider->wordUpperCaseFirstLetter($localisation->getDeptTxt()) . " (" $departementCode ") - Phoniatre : Prenez RDV en ligne";
  256.             // TITRE DE RECHERCHE
  257.             $search_location $departementTexte;
  258.             // TOUTES LES VILLES DU DEPARTEMENT 
  259.             if ($departementTexte == 'lyon' || $departementTexte == 'paris' || $departementTexte == 'marseille') {
  260.                 $citiesInDept $this->getDoctrine()->getRepository(Zipcode::class)->findBy(['city' => $departementTexte]);
  261.                 $this->breadDatas['type'] = 'city';
  262.                 $title_seo "ORL " $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" $departementCode ") - Phoniatre : Prenez RDV en ligne";
  263.                 $this->breadDatas['final'] = $this->dataProvider->wordUpperCaseFirstLetter($departementTexte) . " (" $departementCode ")";
  264.                 // BREADCRUMB SPECIFIQUE
  265.                 switch ($departementTexte) {
  266.                     case 'paris':
  267.                         $this->breadDatas['departementTxt'] = 'Paris';
  268.                         $this->breadDatas['departementCode'] = 75;
  269.                         break;
  270.                     case 'lyon':
  271.                         $this->breadDatas['departementTxt'] = 'Rhône';
  272.                         $this->breadDatas['departementCode'] = 69;
  273.                         break;
  274.                     case 'marseille':
  275.                         $this->breadDatas['departementTxt'] = 'Bouches-du-Rhône';
  276.                         $this->breadDatas['departementCode'] = 13;
  277.                         break;
  278.                 }
  279.             } else {
  280.                 $citiesInDept $this->getDoctrine()->getRepository(Zipcode::class)->findCitiesInDept($departementCode);
  281.             }
  282.             // TOUS LES DOCTEURS DE TOUTES LES VILLES
  283.             foreach ($citiesInDept as $city) {
  284.                 $doctorsincity $this->getDoctrine()->getRepository(Doctors::class)->findByLocalisation($city->getId());
  285.                 foreach ($doctorsincity as $doctorincity) {
  286.                     if (!in_array($doctorincity$doctors)) {
  287.                         $doctorincity->zip $city->getZipcode();
  288.                         array_push($doctors$doctorincity);
  289.                     }
  290.                 }
  291.             }
  292.             $datasFilters = array('departementCode' => $departementCode'departementTexte' => $departementTexte);
  293.             // Description seo //
  294.             //---- On cherche l'objet Map ayant le nom qui commence par depcode %
  295.             $maps $this->getDoctrine()->getRepository(Maps::class)->findOneMapByDepCode($departementCode);
  296.             if ($maps && isset($maps[0])) {
  297.                 $doctors_title_seo $maps[0]->getDoctorsTitleSeo();
  298.                 $doctors_description_seo html_entity_decode($maps[0]->getDoctorsDescriptionSeo(), ENT_QUOTES);
  299.             }
  300.             $canonical_url $this->router->generate('results_medecin_by_departement', array('departementCode' => $departementCode'departementTexte' => $this->slugify->slugify($departementTexte)));
  301.             $centers_url $this->router->generate('results_centres_audio_by_departement', array('departementCode' => $departementCode'departementTexte' => $this->slugify->slugify($departementTexte)));
  302.             //$audio_url = $this->router->generate('results_audio_by_departement', array('departementCode' => $departementCode, 'departementTexte' => $this->slugify->slugify($departementTexte)));
  303.             $ortho_url $this->router->generate('results_ortho_by_departement', array('departementCode' => $departementCode'departementTexte' => $this->slugify->slugify($departementTexte)));
  304.         }
  305.         // Récupération des filtres phoniatres
  306.         $phoniatre_filters $this->FiltersProvider->getMedecinPhoniatreFilters($doctors$datasFilters);
  307.         // Récupération des filtres spécialités
  308.         $specialite_filters $this->FiltersProvider->getMedecinSpecialiteFilters($doctors$datasFilters);
  309.         // Récupération des filtres exercices
  310.         $exercice_filters $this->FiltersProvider->getMedecinExerciceFilters($doctors$datasFilters);
  311.         $filtered false;
  312.         $doctors_filtered = array();
  313.         // SI filtre par phoniatre
  314.         if ($isPhoniatre) {
  315.             foreach ($doctors as $doctor) {
  316.                 if (($doctor->getPhoniatricians() && $isPhoniatre == "oui") || (!$doctor->getPhoniatricians() && $isPhoniatre == "non")) {
  317.                     $doctors_filtered[] = $doctor;
  318.                 }
  319.             }
  320.             $filtered true;
  321.         }
  322.         // Si filtre par spécialité
  323.         if ($idspecialite) {
  324.             foreach ($doctors as $doctor) {
  325.                 $degree $this->getDoctrine()->getRepository(DoctorDegrees::class)->findOneBy(['doctor' => $doctor->getId(), 'degree' => $idspecialite]);
  326.                 if ($degree) {
  327.                     $doctors_filtered[] = $doctor;
  328.                 }
  329.             }
  330.             $filtered true;
  331.         }
  332.         // SI filtre par exercice
  333.         if ($exercice) {
  334.             foreach ($doctors as $doctor) {
  335.                 if ($exercice == 'liberal') {
  336.                     $cabinet $this->getDoctrine()->getRepository(DoctorPractices::class)->findOneBy(['doctorId' => $doctor->getId()]);
  337.                     if ($cabinet)
  338.                         $doctors_filtered[] = $doctor;
  339.                 } else if ($exercice == 'hospitalier') {
  340.                     $service $this->getDoctrine()->getRepository(ServiceDoctors::class)->findOneBy(['doctorId' => $doctor->getId()]);
  341.                     if ($service)
  342.                         $doctors_filtered[] = $doctor;
  343.                 }
  344.             }
  345.             $filtered true;
  346.         }
  347.         if ($filtered) {
  348.             $result $this->cardProvider->getDoctorsCards($doctors_filtered);
  349.         } else {
  350.             $result $this->cardProvider->getDoctorsCards($doctors);
  351.         }
  352.         // PAGINATION
  353.         $results_paginated $paginator->paginate(
  354.             $result,
  355.             $request->query->getInt('page'1),
  356.             30
  357.         );
  358.         $map = array();
  359.         foreach ($results_paginated as $result_paginated) {
  360.             if (array_key_exists('hospital'$result_paginated)) {
  361.                 if ($marker $this->geoProvider->getHospitalCoords($result_paginated['hospital'], $result_paginated['image'], 'Docteur'$result_paginated['doctor']->getTitle())) {
  362.                     $map['markers'][] = $marker;
  363.                 }
  364.             } else if (array_key_exists('practice'$result_paginated)) {
  365.                 if ($marker $this->geoProvider->getPracticeCoords($result_paginated['practice'], $result_paginated['image'], 'Docteur'$result_paginated['doctor']->getTitle())) {
  366.                     $map['markers'][] = $marker;
  367.                 }
  368.             }
  369.         }
  370.         // INJECTION DANS VUE
  371.         $this->setTemplateParameters(array(
  372.             'searchresult' => array('orl' => $results_paginated),
  373.             'filter' => array(
  374.                 'specialites' => $specialite_filters,
  375.                 'phoniatre' => $phoniatre_filters,
  376.                 'exercice' => $exercice_filters,
  377.             )
  378.         ));
  379.         //$this->breadDatas['ville'] = $ville;
  380.         //$this->breadDatas['zipcode'] = $zipcode;
  381.         $this->setBreadcrumb('medecins''list');
  382.         // PREFOOTER
  383.         $searchtype['lng'] = $lng;
  384.         $searchtype['lat'] = $lat;
  385.         $searchtype['localisationId'] = $localisationId;
  386.         $this->setTemplateParameters(array('map' => $map));
  387.         $deptForPreFooter = ($departementTexte == "paris" || $ville == "paris" || $departementTexte == "marseille" || $ville == "marseille" || $departementTexte == "lyon" || $ville == "lyon") ? "à " $departementTexte "en " $departementTexte;
  388.         $this->setTemplateParameters(array('dept' => $deptForPreFooter));
  389.         $this->setTitleSearch();
  390.         $this->setPrevNextRel(count($result), $request->query->getInt('page'), $request->getSchemeAndHttpHost() . $request->getPathInfo());
  391.         $this->setInternalLinkage('medecinListe'$searchtype);
  392.         $this->setTemplateParameters(array('title_seo' => $title_seo));
  393.         $this->setTemplateParameters(array('description_seo' => $description_seo));
  394.         $this->setTemplateParameters(array('seo_text' => array('title' => $doctors_title_seo'text' => $doctors_description_seo)));
  395.         $this->setTemplateParameters(array('canonical_url' => $canonical_url));
  396.         $this->setTemplateParameters(array(
  397.             'centers_url' => $centers_url,
  398.             //'audio_url' =>$audio_url, 
  399.             'ortho_url' => $ortho_url
  400.         ));
  401.         return $this->renderTemplate('pages/annuaire_searchResults_ORL.twig');
  402.     }
  403.     /**
  404.      * @Route("/medecin-ORL-phoniatre/{ville}-{zipcode}/{nomMedecin}-{idMedecin}-practice-{idPractice}.html", name="page_single_medecin_with_practice", requirements={"zipcode"="\d{5}", "nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+", "ville"="[a-zA-Z0-9\-_\/]+", "idPractice"="[0-9]+"})
  405.      *
  406.      * @Route("/medecin-ORL-phoniatre/{ville}-{zipcode}/{nomMedecin}-{idMedecin}-service-{idService}.html", name="page_single_medecin_with_service", requirements={"zipcode"="\d{5}", "nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+", "ville"="[a-zA-Z0-9\-_\/]+", "idService"="[0-9]+"})
  407.      *
  408.      * @Route("/medecin-ORL-phoniatre/{ville}-{zipcode}/{nomMedecin}-{idMedecin}.html", name="page_single_medecin", requirements={"zipcode"="\d{5}", "nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+", "ville"="[a-zA-Z0-9\-_\/]+"})
  409.      * @Route("/medecin-ORL-phoniatre/{nomMedecin}-{idMedecin}.html", name="page_single_medecin_alone", requirements={"nomMedecin"="[a-zA-Z0-9\-_\/]+", "idMedecin"="[0-9]+"})
  410.      */
  411.     public function renderPage($ville null$zipcode null$nomMedecin null$idMedecin null$idPractice null$idService nullRequest $request): Response
  412.     {
  413.         $team = [];
  414.         $page_provider = [];
  415.         $url_practice $url_service null;
  416.         $doctor $this->getDoctrine()->getRepository(Doctors::class)->findOneBy(['id' => $idMedecin'visible' => 1]);
  417.         if (!$doctor) {
  418.             if ($zipcode) {
  419.                 return $this->redirectProvider->redirect301('results_medecin_audio_by_city', array('zipcode' => $zipcode'ville' => $ville));
  420.             } else {
  421.                 return $this->redirectProvider->redirect301('liste_medecin');
  422.             }
  423.         }
  424.         $cabinet $service null;
  425.         $slugMedecin $this->slugify->slugify($doctor->getFirstName() . '-' $doctor->getName());
  426.         if ($slugMedecin != $nomMedecin) {
  427.             if ($idPractice) {
  428.                 return $this->redirectProvider->redirect301('page_single_medecin_with_practice', array('zipcode' => $zipcode'ville' => $ville'nomMedecin' => $slugMedecin'idMedecin' => $idMedecin'idPractice' => $idPractice));
  429.             } else if ($idService) {
  430.                 return $this->redirectProvider->redirect301('page_single_medecin_with_service', array('zipcode' => $zipcode'ville' => $ville'nomMedecin' => $slugMedecin'idMedecin' => $idMedecin'idService' => $idService));
  431.             } else {
  432.                 return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $slugMedecin'idMedecin' => $idMedecin));
  433.             }
  434.         }
  435.         $alone false;
  436.         if (!$idPractice && !$idService) {
  437.             $alone true;
  438.         }
  439.         if ($idPractice) {
  440.             $cabinet $this->getDoctrine()->getRepository(Practices::class)->find($idPractice);
  441.             if (!$cabinet) {
  442.                 return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $slugMedecin'idMedecin' => $idMedecin));
  443.             }
  444.         } else if ($idService) {
  445.             $service $this->getDoctrine()->getRepository(Services::class)->find($idService);
  446.             if (!$service) {
  447.                 return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $slugMedecin'idMedecin' => $idMedecin));
  448.             }
  449.         }
  450.         /*else {
  451.       $cabinet = $this->getDoctrine()->getRepository(Doctors::class)->findPracticeByDoctorID($idMedecin, null, 1);
  452.       $cabinet = ($cabinet)? $cabinet[0] : NULL;
  453.       if($cabinet) {
  454.         $idPractice = $cabinet->getId();
  455.       }
  456.     }*/
  457.         // Les Autres Cabinets & Services //
  458.         $buttons = [];
  459.         
  460.         $i 1;
  461.         $idspractices = array();
  462.         $practices $this->getDoctrine()->getRepository(Doctors::class)->findPracticeByDoctorID($idMedecin);
  463.         foreach ($practices as $practice) {
  464.             $zipcodeCheck $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['id' => $practice->getLocalisation()->getId()]);
  465.             if ($zipcodeCheck) {
  466.                 if ($practice->getLocalisation()->getZipcode()) {
  467.                     $url $this->router->generate(
  468.                         'page_single_medecin_with_practice',
  469.                         array(
  470.                             'zipcode' => $practice->getLocalisation()->getZipcode(),
  471.                             'nomMedecin' => $slugMedecin,
  472.                             'idMedecin' => $idMedecin,
  473.                             'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
  474.                             'idPractice' => $practice->getId(),
  475.                         )
  476.                     );
  477.                     $url_practice $url;
  478.                     if ($alone) {
  479.                         return $this->redirect($url301);
  480.                     }
  481.                     $idpractice $practice->getId();
  482.                     $idspractices[] = $idpractice;
  483.                     $current = (!$idService && $idpractice == $idPractice) ? true false;
  484.                     array_push($buttons, array(
  485.                         "title" => 'Cabinet ' $i,
  486.                         "url" => "/medecin-ORL-phoniatre/" $this->slugify->slugify($practice->getLocalisation()->getCity()) . "-" $practice->getLocalisation()->getZipcode() . "/" $slugMedecin '-' $idMedecin "-practice-" $idpractice ".html",
  487.                         "current" => $current,
  488.                     ));
  489.                     $i++;
  490.                     if ($current) {
  491.             $doctorPractice $this->getDoctrine()->getRepository(DoctorPractices::class)->findOneBy(['doctorId' => $idMedecin'practice' => $idpractice]);
  492.             $this->setTemplateParameters(array('doctolibIframe' => $doctorPractice->getDoctolibIframe() ?? ''));
  493.                         $phone = (!empty($doctorPractice->getPhone())) ? $doctorPractice->getPhone() : $cabinet->getPhone();
  494.                         if ($practice->getLocalisation()->getZipcode() && $zipcode != $practice->getLocalisation()->getZipcode()) {
  495.                             return $this->redirectProvider->redirect301(
  496.                                 'page_single_medecin_with_practice',
  497.                                 array(
  498.                                     'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
  499.                                     'zipcode' => $practice->getLocalisation()->getZipcode(),
  500.                                     'nomMedecin' => $nomMedecin,
  501.                                     'idMedecin' => $idMedecin,
  502.                                     'idPractice' => $idPractice,
  503.                                 )
  504.                             );
  505.                         }
  506.                         // Infos Cabinet
  507.                         $adresse $cabinet->getAddress() . " \n";
  508.                         if ($cabinet->getAdditionalAddress()) {
  509.                             $adresse .= $cabinet->getAdditionalAddress() . " \n";
  510.                         }
  511.                         $adresse .= $cabinet->getLocalisation()->getZipcode() . ' ' $cabinet->getLocalisation()->getCity() . " \n";
  512.                         if ($cabinet->getPoBox()) {
  513.                             $adresse .= $cabinet->getPoBox() . " \n";
  514.                         }
  515.                         if ($cabinet->getZipCedex()) {
  516.                             $adresse .= $cabinet->getZipCedex() . " ";
  517.                         }
  518.                         if ($cabinet->getCityCedex()) {
  519.                             $adresse .= $cabinet->getCityCedex();
  520.                         }
  521.             
  522.                         $page_provider = array(
  523.                             "coords" => array(
  524.                                 "items" => array(
  525.                                     "tel1" => $phone,
  526.                                     "address" => $cabinet->getAddress() . " \n" $cabinet->getAdditionalAddress(),
  527.                                     "zip" => $cabinet->getLocalisation()->getZipcode(),
  528.                                     "city" => $cabinet->getLocalisation()->getCity(),
  529.                                     "bp" => $cabinet->getPoBox(),
  530.                                     "zipcedex" => $cabinet->getZipCedex(),
  531.                                     "citycedex" => $cabinet->getCityCedex()
  532.                                 ),
  533.                                 "coordTitle" => $practice->getName()
  534.                             )
  535.                         );
  536.                     }
  537.                 }
  538.             }
  539.         }
  540.         if (($idPractice && !in_array($idPractice$idspractices))) {
  541.             $zipcodeCheckCurrent $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['id' => $idPractice]);
  542.             if (!$zipcodeCheckCurrent) {
  543.                 return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $nomMedecin'idMedecin' => $idMedecin));
  544.             }
  545.         }
  546.         $services $this->getDoctrine()->getRepository(Doctors::class)->findServiceByDoctorID($idMedecin);
  547.         $idsservices = array();
  548.         $j 1;
  549.         foreach ($services as $serv) {
  550.             if ($serv->getHospital()->getLocalisation()->getCountry() == "FRANCE" || $serv->getHospital()->getLocalisation()->getCountry() == "") {
  551.                 $url $this->router->generate(
  552.                     'page_single_medecin_with_service',
  553.                     array(
  554.                         'zipcode' => $serv->getHospital()->getLocalisation()->getZipcode(),
  555.                         'nomMedecin' => $slugMedecin,
  556.                         'idMedecin' => $idMedecin,
  557.                         'ville' => $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()),
  558.                         'idService' => $serv->getId()
  559.                     )
  560.                 );
  561.                 $url_service $url;
  562.                 if ($alone) {
  563.                     return $this->redirect($url301);
  564.                 }
  565.                 $idservice $serv->getId();
  566.                 $idsservices[] = $idservice;
  567.                 $current = ($idservice == $idService) ? true false;
  568.                 array_push($buttons, array(
  569.                     "title" => "Service ORL " $j,
  570.                     "url" => "/medecin-ORL-phoniatre/" $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()) . "-" $serv->getHospital()->getLocalisation()->getZipcode() . "/" $slugMedecin '-' $idMedecin "-service-" $idservice ".html",
  571.                     "current" => $current,
  572.                 ));
  573.                 $j++;
  574.                 if ($current) {
  575.                     if ($zipcode != $serv->getHospital()->getLocalisation()->getZipcode()) {
  576.                         return $this->redirectProvider->redirect301(
  577.                             'page_single_medecin_with_service',
  578.                             array(
  579.                                 'ville' => $this->slugify->slugify($serv->getHospital()->getLocalisation()->getCity()),
  580.                                 'zipcode' => $serv->getHospital()->getLocalisation()->getZipcode(),
  581.                                 'nomMedecin' => $nomMedecin,
  582.                                 'idMedecin' => $idMedecin,
  583.                                 'idService' => $idService
  584.                             )
  585.                         );
  586.                     }
  587.                     $page_provider = array(
  588.                         "coords" => array(
  589.                             "items" => array(
  590.                                 "address" => $serv->getHospital()->getAddress() . " \n" $serv->getHospital()->getAdditionalAddress(),
  591.                                 "zip" => $serv->getHospital()->getLocalisation()->getZipcode(),
  592.                                 "city" => $serv->getHospital()->getLocalisation()->getCity(),
  593.                                 "bp" => $serv->getHospital()->getPoBox(),
  594.                                 "zipcedex" => $serv->getHospital()->getCedex(),
  595.                                 "citycedex" => $serv->getHospital()->getCityCedex()
  596.                             ),
  597.                             "coordTitle" => $serv->getHospital()->getCorporateName(),
  598.                             'subtitleORLService' => $serv->getName(),
  599.                             'link' => $url $this->router->generate(
  600.                                 'page_service_hospitalier_avec_service',
  601.                                 array(
  602.                                     'ville' => $ville,
  603.                                     'zipcode' => $zipcode,
  604.                                     'nomhopital' => $this->slugify->slugify($serv->getHospital()->getCorporateName()),
  605.                                     'idhopital' => $serv->getHospital()->getId(),
  606.                                     'nomservice' => $this->slugify->slugify($serv->getName()),
  607.                                     'idservice' => $serv->getId(),
  608.                                 )
  609.                             )
  610.                         )
  611.                     );
  612.                     $serviceDoctor $this->getDoctrine()->getRepository(ServiceDoctors::class)->findOneBy([
  613.                         'service' => $idService,
  614.                         'doctor' => $idMedecin
  615.                     ]);
  616.           $this->setTemplateParameters(array('doctolibIframe' => $serviceDoctor->getDoctolibIframe() ?? ''));
  617.                     if ($serviceDoctor && $serviceDoctor->getTelSpecifique()) {
  618.                         $page_provider['coords']['items']['telSpec'] = $serviceDoctor->getTelSpecifique();
  619.                         $page_provider['coords']['items']['telSpecDesc'] = $serviceDoctor->getTelSpecifiqueDesc();
  620.                     } else {
  621.                         // Infos Cabinet
  622.                         for ($i 1$i <= 3$i++) {
  623.                             $tel $serv->{'getTitle' $i}();
  624.                             if (!empty($tel))
  625.                                 $tel .= "\n";
  626.                             $tel .= $serv->{'getDescription' $i}();
  627.                             $page_provider['coords']['items']['tel' $i] = $tel;
  628.                         }
  629.                     }
  630.                 }
  631.             }
  632.         }
  633.         if ($idService && !in_array($idService$idsservices)) {
  634.             return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $nomMedecin'idMedecin' => $idMedecin));
  635.         }
  636.         $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
  637.             'zipcode' => $zipcode,
  638.             'city' => strtoupper($ville)
  639.         ));
  640.         if (!$localisation) {
  641.             $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(array(
  642.                 'zipcode' => $zipcode,
  643.                 'city' => strtoupper(str_replace('-'' '$ville))
  644.             ));
  645.         }
  646.         if (!$localisation) {
  647.             $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findByZipCodeAndCityLike($zipcode$ville);
  648.         }
  649.         if (!$localisation) {
  650.             $localisation $this->getDoctrine()->getRepository(Zipcode::class)->findOneBy(['zipcode' => $zipcode]);
  651.         }
  652.         if (!$localisation) {
  653.             throw new NotFoundHttpException();
  654.         }
  655.         if ($localisation && ($zipcode != $localisation->getZipcode() || $ville != $this->slugify->slugify($localisation->getCity()))) {
  656.             return $this->redirectProvider->redirect301('page_single_medecin_alone', array('nomMedecin' => $nomMedecin'idMedecin' => $idMedecin));
  657.         }
  658.         //if(!$alone)
  659.         //$slugVille = $this->slugify->slugify($localisation->getCity());
  660.         // Logo //
  661.         $logo $this->dataProvider->getAvatar('Docteur'$doctor->getTitle());
  662.         if ($logoId $this->getDoctrine()->getRepository(Image::class)->findOneBy(['class' => 'Doctors''entityId' => $idMedecin'cover' => 1])) {
  663.             $file $this->bo_url "images/" $logoId->getId() . "-medium.jpg";
  664.             $logo $file;
  665.         }
  666.         // Diplômes //
  667.         $diplomes $this->getDoctrine()->getRepository(Doctors::class)->getDoctorDegrees($idMedecin);
  668.         $diplomas = [];
  669.         foreach ($diplomes as $diplome) {
  670.             $diplomas[] = $diplome->getName();
  671.         }
  672.         if (!empty($doctor->getFreeField())) {
  673.             $diplomas[] = $doctor->getFreeField();
  674.         }
  675.         // Centres à proximités du cabinet //
  676.         // On teste s'il y a un cabinet en paramètre, sinon on récupère le premier cabinet dans la requête.
  677.         $centre_proximite = [];
  678.         if ($cabinet || $service) {
  679.             $object = ($cabinet) ? $cabinet $service;
  680.             // Coordonnées de localisation
  681.             if ($service) {
  682.                 $cities $service->getHospital()->getLocalisation()->getCities();
  683.                 if (!$cities) {
  684.                     $cities $this->geoProvider->addCities($ville$zipcode$localisation);
  685.                 }
  686.                 $geocode $this->dataProvider->getGeoCode($service->getHospital());
  687.             } else {
  688.                 $cities $object->getLocalisation()->getCities();
  689.                 if (!$cities) {
  690.                     $cities $this->geoProvider->addCities($ville$zipcode$localisation);
  691.                 }
  692.                 $geocode $this->dataProvider->getGeoCode($object);
  693.             }
  694.             $lat $geocode['lat'];
  695.             $lng $geocode['lng'];
  696.             $idLoc $geocode['idLoc'];
  697.             $centersCity $this->getDoctrine()->getRepository(Centers::class)->findBy([
  698.                 'localisation' => $localisation->getId(),
  699.                 'advertiser' => 1,
  700.                 'visible' => 1
  701.             ]);
  702.             shuffle($centersCity);
  703.             foreach ($centersCity as $c) {
  704.                 array_push($centre_proximite$c);
  705.             }
  706.             $centersRelated $this->getDoctrine()->getRepository(CenterZipcode::class)->findBy(['zipcodeId' => $localisation->getId()]);
  707.             shuffle($centersRelated);
  708.             foreach ($centersRelated as $c) {
  709.                 $cr $this->getDoctrine()->getRepository(Centers::class)->findOneBy([
  710.                     'id' => $c->getCenterId(),
  711.                     'advertiser' => 1,
  712.                     'visible' => 1
  713.                 ]);
  714.                 if ($cr) {
  715.                     array_push($centre_proximite$cr);
  716.                 }
  717.             }
  718.             if (sizeof($centre_proximite) < 6) {
  719.                 $limit sizeof($centre_proximite);
  720.                 $proximites $this->getDoctrine()->getRepository(Centers::class)->findCentersByProximiteCity(array('lat' => $lat'lng' => $lng), $localisation->getId(), $limit);
  721.                 shuffle($proximites);
  722.                 foreach ($proximites as $proximite) {
  723.                     $centerPro $this->getDoctrine()->getRepository(Centers::class)->findOneBy(['id' => $proximite[0]->getId(), 'visible' => 1]);
  724.                     if ($centerPro && !in_array($centerPro$centre_proximite)) {
  725.                         array_push($centre_proximite$centerPro);
  726.                     }
  727.                 }
  728.             }
  729.             $centre_proximite $this->cardProvider->getCenterCards($centre_proximite);
  730.             // On cherche les autres médecins du même cabinet ou du même service //
  731.             $lieuType null;
  732.             $lieuEntity null;
  733.             if ($cabinet) {
  734.                 $otherDoctors $this->getDoctrine()->getRepository(Doctors::class)->findByPractice($cabinet->getId(), $idMedecin);
  735.                 $lieuType "cabinet";
  736.                 $lieuEntity $cabinet;
  737.             } elseif ($service) {
  738.                 $otherDoctors $this->getDoctrine()->getRepository(Doctors::class)->findByService($service->getId(), $idMedecin);
  739.                 $lieuType "service";
  740.                 $lieuEntity $service;
  741.             }
  742.             $team $this->cardProvider->getOrlCards($otherDoctors$localisation$lieuType$lieuEntity);
  743.         }
  744.         // Les actualités //
  745.         $news = [];
  746.         $a = [];
  747.         $v = [];
  748.         $actualites $this->getDoctrine()->getRepository(NewsDoctors::class)->findNewsByDoctorID($idMedecin);
  749.         if ($actualites) {
  750.             $a $this->cardProvider->getNewsCards($actualites);
  751.         }
  752.         $videos $this->getDoctrine()->getRepository(NewsDoctors::class)->findVideosByDoctorID($idMedecin);
  753.         if ($videos) {
  754.             $v $this->cardProvider->getVideosCards($videos);
  755.         }
  756.         $news array_merge($a$v);
  757.         // Associations //
  758.         $agencies = [];
  759.         $associations $this->getDoctrine()->getRepository(AgencyDoctors::class)->findBy(array('doctor' => $idMedecin));
  760.         if ($associations) {
  761.             $orga = array();
  762.             foreach ($associations as $asso) {
  763.                 $agencie null;
  764.                 $agencie $this->getDoctrine()->getRepository(Agencies::class)->findOneBy(array('id' => $asso->getAgency()->getId()));
  765.                 if ($agencie) {
  766.                     $agencie->role1 $asso->getSpecificity1();
  767.                     $agencie->role2 $asso->getSpecificity2();
  768.                 }
  769.                 array_push($orga$agencie);
  770.             }
  771.             $agencies $this->cardProvider->getAgencyCards($orga$zipcode$villetrue);
  772.         }
  773.         // ROLES
  774.         $servicesDoctors $this->getDoctrine()->getRepository(ServiceDoctors::class)->findBy(array('doctorId' => $idMedecin));
  775.         $rolesDesordre = array();
  776.         $roles = [];
  777.         foreach ($servicesDoctors as $servicesDoctor) {
  778.             $hopital false;
  779.             $lookup $this->getDoctrine()->getRepository(Lookup::class)->findOneBy(['code' => $servicesDoctor->getStatusGrade(), 'type' => 'StatusGrade']);
  780.             $serviceD $this->getDoctrine()->getRepository(Services::class)->findOneBy(['id' => $servicesDoctor->getService()]);
  781.             if ($serviceD) {
  782.                 $hopital $this->getDoctrine()->getRepository(Hospitals::class)->findOneBy(['id' => $serviceD->getHospital()]);
  783.             }
  784.             $cityhospital "";
  785.             if ($hopital && $hopital->getLocalisation()->getCity())
  786.                 $cityhospital " de " $hopital->getLocalisation()->getCity();
  787.             if ($lookup && $hopital) {
  788.                 $nom $lookup->getName();
  789.                 if (!empty($servicesDoctor->getSpecialty()))
  790.                     $nom .= " (" $servicesDoctor->getSpecialty() . ")";
  791.                 $nom .= " " $hopital->getCorporateName() . $cityhospital;
  792.                 $rolesDesordre[] = array(
  793.                     'nom' => $nom,
  794.                     'position' => $lookup->getPosition()
  795.                 );
  796.             }
  797.         }
  798.         $pos array_column($rolesDesordre'position');
  799.         array_multisort($posSORT_ASC$rolesDesordre);
  800.         foreach ($rolesDesordre as $r) {
  801.             $roles[] = $r['nom'];
  802.         }
  803.         // Titres organismes
  804.         if (isset($orga)) {
  805.             foreach ($orga as $agencie) {
  806.                 $rolePerson "";
  807.                 if ($agencie->role1)
  808.                     $rolePerson $agencie->role1;
  809.                 if ($agencie->role2)
  810.                     $rolePerson .= ", " $agencie->role2;
  811.                 if ($agencie->role1 || $agencie->role2)
  812.                     $rolePerson .= " " $agencie->getCorporateName();
  813.                 $roles[] = $rolePerson;
  814.             }
  815.         }
  816.         // Header //
  817.         $header = array(
  818.             "image" => $logo,
  819.             "name" => $doctor->getFirstName(),
  820.             "surname" => $doctor->getName(),
  821.             "grade" => $doctor->getTitle(),
  822.             "job" => $this->dataProvider->getDoctorSpecialities($idMedecin),
  823.             "roles" => $roles,
  824.         );
  825.         $this->setTemplateParameters(array(
  826.             "page_orl" => array(
  827.                 "header" => $header,
  828.                 "diplomas" => $diplomas,
  829.                 "centers" => $centre_proximite,
  830.                 "team" => $team,
  831.                 "type" => ($service) ? 'service' 'cabinet',
  832.                 "actus" => $news,
  833.                 "associations" => $agencies,
  834.                 "lieuType" => ($service) ? 'service ORL' 'cabinet',
  835.             ),
  836.             'search' => array(
  837.                 'filter' => $buttons,
  838.             ),
  839.             "page_provider" => $page_provider,
  840.         ));
  841.         if (!$alone) {
  842.             if (!isset($lat)) {
  843.                 $lat $localisation->getCities()->getLat();
  844.                 $lng $localisation->getCities()->getLng();
  845.                 $idLoc $localisation->getCities()->getId();
  846.             }
  847.             $searchtype['lat'] = $lat;
  848.             $searchtype['lng'] = $lng;
  849.             $searchtype['currentCityId'] = $idLoc;
  850.             $this->setTemplateParameters(array('city' => $localisation->getCity()));
  851.             $map['markers'][] = array(
  852.                 "lat" => $lat,
  853.                 "lon" => $lng,
  854.                 "premium" => true,
  855.                 "src" => "url(" $logo ")"
  856.             );
  857.             $this->setInternalLinkage('medecinPage'$searchtype);
  858.             $dep $localisation->getDepartment();
  859.             $departementTxt $localisation->getCities()->getDeptTxt();
  860.             $departementCode $localisation->getCities()->getDeptCode();
  861.             $this->breadDatas['ville'] = $localisation->getCity();
  862.             $this->breadDatas['zipcode'] = $localisation->getZipcode();
  863.             $this->breadDatas['departementTxt'] = $departementTxt;
  864.             $this->breadDatas['departementCode'] = $departementCode;
  865.             $this->setTemplateParameters(array('map' => $map));
  866.         }
  867.         if ($zipcode && $ville) {
  868.             $centers_url $this->router->generate('results_centres_audio_by_city', array('zipcode' => $zipcode'ville' => $this->slugify->slugify($ville)));
  869.             //$audio_url = $this->router->generate('results_audio_by_city', array('zipcode' => $zipcode, 'ville' => $this->slugify->slugify($ville)));
  870.             $ortho_url $this->router->generate('results_ortho_audio_by_city', array('zipcode' => $zipcode'ville' => $this->slugify->slugify($ville)));
  871.         }
  872.         /************** Titre seo ***************/
  873.         $title_seo $doctor->getFirstName() . ' ' $doctor->getName() . ' - Médecin ORL';
  874.         if ($ville) {
  875.             $title_seo .=  ' à ' $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . ' (' $zipcode ')';
  876.             /************** Description seo ***************/
  877.             $description_seo "Prenez rendez-vous avec " $doctor->getFirstName() . " " $doctor->getName() . ", médecin ORL à " $this->dataProvider->wordUpperCaseFirstLetter($localisation->getCity()) . " (" $zipcode "). Consultez ses coordonnées et son adresse sur l'Annuaire de l'Audition.";
  878.         }
  879.         $canonical_url null;
  880.         if ($url_practice) {
  881.             $canonical_url $url_practice;
  882.     }
  883.         elseif ($url_service) {
  884.             $canonical_url $url_service;
  885.     }
  886.         else {
  887.             $canonical_url $this->dataProvider->getDoctorLink($idMedecin);
  888.     }
  889.         $this->setTemplateParameters(array('title_seo' => $title_seo));
  890.         $this->setTemplateParameters(array('description_seo' => $description_seo ?? ""));
  891.         $this->setTemplateParameters(array('canonical_url' => $canonical_url));
  892.         $this->breadDatas['final'] = $doctor->getFirstName() . ' ' $doctor->getName();
  893.         // Breadcrumb
  894.         $this->setBreadcrumb('medecins''single');
  895.         $this->setTemplateParameters(array('dataLayerCenters' => $centre_proximite'creative' => 'fiche-pro'));
  896.         $this->setTemplateParameters(array(
  897.             'centers_url' => $centers_url ?? "",
  898.             //'audio_url' =>$audio_url ?? "",
  899.             'ortho_url' => $ortho_url ?? ""
  900.         ));
  901.         if ($idPractice$this->setTemplateParameters(array('idPractice' => $idPractice));
  902.         if ($idService)  $this->setTemplateParameters(array('idService' => $idService));
  903.         if ($idPractice || $idService) {
  904.             $id_entity $idPractice ?? $idService;
  905.             $entity $idPractice 'practice' 'service';
  906.             // on cherche le cache des parkings
  907.             if (file_exists('overpass/parkings/' $entity '/' $entity '-' intval($id_entity) . '.json')) {
  908.                 $data json_decode(file_get_contents('overpass/parkings/' $entity '/' $entity '-' intval($id_entity) . '.json'));
  909.                 $parkings $this->renderView('modules/map/nearby.html.twig', array(
  910.                     'type' => "parkings",
  911.                     'parkings' => (array)$data
  912.                 ));
  913.                 $this->setTemplateParameters(array('parkings' => $parkings));
  914.             }
  915.             $transport_communs = [];
  916.             // on cherche le cache des bus
  917.             if (file_exists('overpass/buses/' $entity '/' $entity '-' intval($id_entity) . '.json')) {
  918.                 $data json_decode(file_get_contents('overpass/buses/' $entity '/' $entity '-' intval($id_entity) . '.json'));
  919.                 if ($data) {
  920.                     $transport_communs['buses'] = $data;
  921.                 }
  922.                 $buses $this->renderView('modules/map/nearby.html.twig', array(
  923.                     'type' => "transport",
  924.                     'subtype' => "buses",
  925.                     'buses' => (array)$data
  926.                 ));
  927.                 $this->setTemplateParameters(array('buses' => $buses));
  928.             }
  929.             // on cherche le cache des métros/trains
  930.             if (file_exists('overpass/subways/' $entity '/' $entity '-' intval($id_entity) . '.json')) {
  931.                 $data json_decode(file_get_contents('overpass/subways/' $entity '/' $entity '-' intval($id_entity) . '.json'));
  932.                 if ($data) {
  933.                     $transport_communs['subways'] = $data;
  934.                 }
  935.                 $subways $this->renderView('modules/map/nearby.html.twig', array(
  936.                     'type' => "transport",
  937.                     'subtype' => "subways",
  938.                     'subways' => (array)$data
  939.                 ));
  940.                 $this->setTemplateParameters(array('subways' => $subways));
  941.             }
  942.             // on cherche le cache des trams.
  943.             if (file_exists('overpass/trams/' $entity '/' $entity '-' intval($id_entity) . '.json')) {
  944.                 $data json_decode(file_get_contents('overpass/trams/' $entity '/' $entity '-' intval($id_entity) . '.json'));
  945.                 if ($data) {
  946.                     $transport_communs['trams'] = $data;
  947.                 }
  948.                 $trams $this->renderView('modules/map/nearby.html.twig', array(
  949.                     'type' => "transport",
  950.                     'subtype' => "trams",
  951.                     'trams' => (array)$data
  952.                 ));
  953.                 $this->setTemplateParameters(array('trams' => $trams));
  954.             }
  955.         }
  956.         // FAQ //
  957.         $faqs = [];
  958.         $nomMedecin $doctor->getTitle() . ' ' $doctor->getFirstName() . ' ' $doctor->getName();
  959.         $entity $cabinet;
  960.         if (!$cabinet && $service && $service->getHospital()) $entity $service->getHospital();
  961.         if ($entity) {
  962.             $address $entity->getAddress();
  963.             if ($entity->getLocalisation() && $entity->getLocalisation()->getId()) {
  964.                 $address .= " " $entity->getLocalisation()->getZipcode() . " " $entity->getLocalisation()->getCity();
  965.             }
  966.             $faqs[] = [
  967.                 "question" => "Quelle est l'adresse du " $nomMedecin " ?",
  968.                 "response" => "L'adresse du " $nomMedecin " est " $address
  969.             ];
  970.             $phone $entity->getPhone();
  971.             if ($phone) {
  972.                 $faqs[] = [
  973.                     "question" => "Comment contacter le " $nomMedecin " ?",
  974.                     "response" => "Il est possible de contacter le " $nomMedecin " par téléphone au " $phone "."
  975.                 ];
  976.             }
  977.       
  978.         }
  979.         if ($diplomas) {
  980.             $suffix = (sizeof($diplomas) > 1) ? "s" "";
  981.             $response_txt "Le " $nomMedecin " possède le" $suffix " diplôme" $suffix " suivant" $suffix " :<ul>";
  982.             foreach ($diplomas as $diplome) {
  983.                 $response_txt .= "<li>" $diplome "</li>";
  984.             }
  985.             $response_txt .= "</ul>";
  986.             $faqs[] = [
  987.                 "question" => "Quelle est la formation et quels sont les diplômes du " $nomMedecin " ?",
  988.                 "response" => $response_txt
  989.             ];
  990.         }
  991.         if ((sizeof($idsservices) + sizeof($idspractices) > 1)) {
  992.             $suffix = (sizeof($idsservices) + sizeof($idspractices) > 1) ? "s" "";
  993.             $suffixX = (sizeof($idsservices) + sizeof($idspractices) > 1) ? "x" "";
  994.             $response_txt "";
  995.             foreach ($practices as $practice) {
  996.                 $response_txt .= "<li>" $practice->getName();
  997.                 if ($practice->getLocalisation() && $practice->getLocalisation()->getId()) {
  998.                     $response_txt .= " à " $practice->getLocalisation()->getCity();
  999.                 }
  1000.                 $response_txt .= "</li>";
  1001.             }
  1002.             foreach ($services as $service) {
  1003.                 $service $service->getHospital();
  1004.                 $response_txt .= "<li>" $service->getCorporateName();
  1005.                 if ($service->getLocalisation() && $service->getLocalisation()->getId()) {
  1006.                     $response_txt .= " à " $service->getLocalisation()->getCity();
  1007.                 }
  1008.                 $response_txt .= "</li>";
  1009.             }
  1010.             if ($response_txt) {
  1011.                 $faqs[] = [
  1012.                     "question" => "Où exerce le " $nomMedecin " ?",
  1013.                     "response" => "Le " $nomMedecin " exerce dans les " . (sizeof($idsservices) + sizeof($idspractices)) . " lieu" $suffixX " suivant" $suffix " :<ul>" $response_txt "</ul>"
  1014.                 ];
  1015.             }
  1016.         }
  1017.         $placeType $cabinet "cabinet ORL" "service ORL";
  1018.         if ($otherDoctors) {
  1019.             $suffix sizeof($otherDoctors) > "s" "";
  1020.             $suffix_ENT sizeof($otherDoctors) > "nt" "";
  1021.             $placeAddress " " $entity->getAddress();
  1022.             if ($entity->getLocalisation() && $entity->getLocalisation()->getId()) {
  1023.                 $placeAddress .= " " $entity->getLocalisation()->getZipcode() . " " $entity->getLocalisation()->getCity();
  1024.             }
  1025.             $response_txt "";
  1026.             foreach ($otherDoctors as $doc) {
  1027.                 $response_txt .= "<li>" $doc->getTitle() . " " $doc->getFirstName() . " " $doc->getName() . "</li>";
  1028.             }
  1029.             $faqs[] = [
  1030.                 "question" => "Quels sont les autres médecins ORL du " $placeType " " $placeAddress " ?",
  1031.                 "response" => sizeof($otherDoctors) . " autre" $suffix " médecin" $suffix " ORL exerce" $suffix_ENT " également dans le " $placeType " du " $nomMedecin " :<ul>" $response_txt "</ul>"
  1032.             ];
  1033.         }
  1034.         if ($transport_communs) {
  1035.             $response_txt "";
  1036.             foreach ($transport_communs as $type => $tc) {
  1037.                 $type $type == 'buses' 'Bus - ' : ($type == 'subways' 'Métro - ' 'Tram - ');
  1038.                 foreach ($tc as $value) {
  1039.                     $response_txt .= "<li>" $type $value->name "</li>";
  1040.                 }
  1041.             }
  1042.             $faqs[] = [
  1043.                 "question" => "Comment accéder au " $placeType " du " $nomMedecin " par les transports en commun ?",
  1044.                 "response" => "Le " $placeType " du " $nomMedecin " est situé à proximité des arrêts suivants :<ul>" $response_txt "</ul>"
  1045.             ];
  1046.         }
  1047.         $this->setTemplateParameters(array('faqs' => $faqs));
  1048.         return $this->renderTemplate('pages/annuaire_page_ORL.twig', [
  1049.             'idMedecin' => $idMedecin,
  1050.         ]);
  1051.     }
  1052.   /**
  1053.    * @Route("/import-doctolib-links", name="import_doctolib_links")
  1054.    */
  1055.   public function importDoctolibLinks(
  1056.     DoctorPracticesRepository $doctorPracticesRepository,
  1057.     ServiceDoctorsRepository $serviceDoctorsRepository,
  1058.     EntityManagerInterface $em,
  1059.     Request $request
  1060.   ) {
  1061.     if (!$request->query->get('filename')) {
  1062.       die('No file exists');
  1063.     }
  1064.     $inputFileName 'imports/' $request->query->get('filename');
  1065.     $spreadsheet IOFactory::load($inputFileName);
  1066.     $sheetData $spreadsheet->getActiveSheet()->toArray();
  1067.     unset($sheetData[0]);
  1068.     $prefix "https://partners.doctolib.fr/orl/";
  1069.     $slugify = new Slugify();
  1070.     foreach ($sheetData as $row)
  1071.     {
  1072.       if (empty($row[0])) break;
  1073.       
  1074.       $url $prefix $slugify->slugify($row[13]) . '/' $slugify->slugify($row[8]) . '-' $slugify->slugify($row[9]);
  1075.       $urlImported false;
  1076.       $idCabService $row[3];
  1077.       // Check practices.
  1078.       /** @var [] DoctorPractices */
  1079.       $doctorPractices $doctorPracticesRepository->findBy(['doctorId' => $row[0]]);
  1080.       if (count($doctorPractices)) {
  1081.         foreach ($doctorPractices as $doctorPractice) {
  1082.           /**
  1083.            * @var Practices $practice
  1084.            */
  1085.           $practice $doctorPractice->getPractice();
  1086.           $idCabService $row[3];
  1087.           if ($idCabService == $practice->getId()) {
  1088.             $doctorPractice->setDoctolibIframe($url);
  1089.             $em->persist($doctorPractice);
  1090.             $em->flush();
  1091.             $urlImported true;
  1092.             break;
  1093.           }
  1094.         }
  1095.       }
  1096.       // Check services.
  1097.       if (!$urlImported) {
  1098.         $services $serviceDoctorsRepository->findBy(['doctorId' => $row[0]]);
  1099.         if (count($services)) {
  1100.           foreach ($services as $serviceDoctor) {
  1101.             if ($idCabService == $serviceDoctor->getService()->getId()) {
  1102.               $serviceDoctor->setDoctolibIframe($url);
  1103.               $em->persist($serviceDoctor);
  1104.               $em->flush();
  1105.               $urlImported true;
  1106.               break;
  1107.             }
  1108.           }
  1109.         }
  1110.       }
  1111.       if (!$urlImported) {
  1112.         echo $row[0] . ' - ' $url '<br>';
  1113.       }
  1114.     }
  1115.     die('Import done');
  1116.   }
  1117.   /**
  1118.    * @Route("/get-all-orls-having-doctolib-iframe", name="get_all_orls_having_doctolib_iframe")
  1119.    */
  1120.   public function getAllOrlsHavingDoctolibIframe(
  1121.     DoctorPracticesRepository $doctorPracticesRepository,
  1122.     ServiceDoctorsRepository $serviceDoctorsRepository
  1123.   ) {
  1124.     $siteUrl $_SERVER['REQUEST_SCHEME'] . '://' $_SERVER['HTTP_HOST'];
  1125.     $urls '';
  1126.     // Practices.
  1127.     $doctorPractices $doctorPracticesRepository->findAllHavingDoctolibIframe();
  1128.     foreach ($doctorPractices as $doctorPractice) {
  1129.       $practice $doctorPractice->getPractice();
  1130.       if ($practice->getLocalisation()->getCountry() != 'FRANCE') {
  1131.         continue;
  1132.       }
  1133.       $doctor $doctorPractice->getDoctor();
  1134.       if (!$doctor || !$practice) continue;
  1135.       $slugMedecin $this->slugify->slugify($doctor->getFirstName() . '-' $doctor->getName());
  1136.       $urls .= $siteUrl $this->router->generate(
  1137.         'page_single_medecin_with_practice',
  1138.         array(
  1139.           'zipcode' => $practice->getLocalisation()->getZipcode(),
  1140.           'nomMedecin' => $slugMedecin,
  1141.           'idMedecin' => $doctor->getId(),
  1142.           'ville' => $this->slugify->slugify($practice->getLocalisation()->getCity()),
  1143.           'idPractice' => $practice->getId(),
  1144.         )
  1145.       ) . '<br>';
  1146.     }
  1147.     // Services.
  1148.     $servicesDoctors $serviceDoctorsRepository->findAllHavingDoctolibIframe();
  1149.     foreach ($servicesDoctors as $serviceDoctor) {
  1150.       $service $serviceDoctor->getService();
  1151.       if ($service->getHospital()->getLocalisation()->getCountry() !== 'FRANCE') {
  1152.         continue;
  1153.       }
  1154.       $doctor $serviceDoctor->getDoctor();
  1155.       if (!$doctor || !$practice) continue;
  1156.       $slugMedecin $this->slugify->slugify($doctor->getFirstName() . '-' $doctor->getName());
  1157.       $urls .= $siteUrl $this->router->generate(
  1158.         'page_single_medecin_with_service',
  1159.         array(
  1160.           'zipcode' => $service->getHospital()->getLocalisation()->getZipcode(),
  1161.           'nomMedecin' => $slugMedecin,
  1162.           'idMedecin' => $doctor->getId(),
  1163.           'ville' => $this->slugify->slugify($service->getHospital()->getLocalisation()->getCity()),
  1164.           'idService' => $service->getId()
  1165.         )
  1166.       ) . '<br>';
  1167.     }
  1168.     die($urls);
  1169.   }
  1170. }