src/Controller/Api/Factory/ApiWidgetsController.php line 1157

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Api\Factory;
  3. use App\Entity\Adherent\Annuaire\MagasinContact;
  4. use App\Entity\Adherent\Magasin;
  5. use App\Entity\Adherent\MagasinCollaborateurs;
  6. use App\Entity\Adherent\MagasinCoordonnees;
  7. use App\Entity\Adherent\MagasinEquipe;
  8. use App\Entity\Adherent\MagasinMarques;
  9. use App\Entity\Adherent\MagasinUrl;
  10. use App\Entity\Image\Image;
  11. use App\Entity\ImagePartner;
  12. use App\Entity\OffresConso\OffreInscription;
  13. use App\Entity\OffresConso\OffreWeb;
  14. use App\Entity\Webfactory\Actualites\WebfactoryActualite;
  15. use App\Entity\Webfactory\Actualites\WebfactoryActualiteCategory;
  16. use App\Entity\Webfactory\AnnouncementBar;
  17. use App\Entity\Webfactory\CustomCssJs;
  18. use App\Entity\Webfactory\SeoVilles;
  19. use App\Entity\Webfactory\SeoVillesContenus;
  20. use App\Entity\Webfactory\WebfactoryFittingBoxImg;
  21. use App\Entity\Webfactory\WebfactoryPage;
  22. use App\Entity\Webfactory\WebfactoryWidget;
  23. use App\Entity\Webfactory\Widget\SiteWebService;
  24. use App\Entity\Webfactory\Widget\SiteWebSpecialite;
  25. use App\Entity\Webfactory\Widget\WidgetAbstract;
  26. use App\Enum\FactoryEnum;
  27. use App\Helper\Factory\FactoryHelper;
  28. use App\Helper\FiltersReviewsHelper;
  29. use App\Manager\Crm\CrmAccessManager;
  30. use App\Manager\Crm\RcuManager;
  31. use App\Manager\DatasProgress;
  32. use App\Manager\OpcManager;
  33. use App\Manager\QueryProgress;
  34. use App\Manager\Webfactory\MarquesManager;
  35. use App\Manager\Webfactory\WebfactoryManager;
  36. use App\Manager\WsProgressManager;
  37. use Cocur\Slugify\Slugify;
  38. use Doctrine\Common\Collections\Criteria;
  39. use Doctrine\ORM\EntityManagerInterface;
  40. use Doctrine\ORM\NonUniqueResultException;
  41. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  42. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  43. use Symfony\Component\HttpFoundation\JsonResponse;
  44. use Symfony\Component\HttpFoundation\Request;
  45. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  46. use Symfony\Component\Routing\Annotation\Route;
  47. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  48. use Symfony\Contracts\HttpClient\HttpClientInterface;
  49. use Symfony\Contracts\Translation\TranslatorInterface;
  50. /**
  51.  * @Route("/api/v1")
  52.  */
  53. class ApiWidgetsController extends AbstractController
  54. {
  55.     private $entityManager;
  56.     private $wsProgressManager;
  57.     private $datasProgress;
  58.     private $webfactoryManager;
  59.     private $session;
  60.     private $translator;
  61.     private $factoryHelper;
  62.     private $rcuManager;
  63.     private $crmAccessManager;
  64.     private $cdnOpc;
  65.     private $opcManager;
  66.     private $marquesManager;
  67.     private $langs;
  68.     private $urlPhotosAdh;
  69.     /**
  70.      * @param EntityManagerInterface $entityManager
  71.      * @param WsProgressManager $wsProgressManager
  72.      * @param DatasProgress $datasProgress
  73.      * @param WebfactoryManager $webfactoryManager
  74.      * @param SessionInterface $session
  75.      */
  76.     public function __construct(
  77.         FactoryHelper                $factoryHelper,
  78.         EntityManagerInterface       $entityManager,
  79.         WsProgressManager            $wsProgressManager,
  80.         DatasProgress                $datasProgress,
  81.         WebfactoryManager            $webfactoryManager,
  82.         SessionInterface             $session,
  83.         TranslatorInterface          $translator,
  84.         RcuManager                   $rcuManager,
  85.         CrmAccessManager             $crmAccessManager,
  86.         ParameterBagInterface        $parameterBag,
  87.         OpcManager                   $opcManager,
  88.         MarquesManager               $marquesManager,
  89.         private HttpClientInterface  $client,
  90.         private FiltersReviewsHelper $filtersReviewsHelper
  91.     )
  92.     {
  93.         $this->entityManager $entityManager;
  94.         $this->wsProgressManager $wsProgressManager;
  95.         $this->datasProgress $datasProgress;
  96.         $this->webfactoryManager $webfactoryManager;
  97.         $this->session $session;
  98.         $this->translator $translator;
  99.         $this->factoryHelper $factoryHelper;
  100.         $this->rcuManager $rcuManager;
  101.         $this->crmAccessManager $crmAccessManager;
  102.         $this->cdnOpc $parameterBag->get('twicpics_domain_images_OPC');
  103.         $this->opcManager $opcManager;
  104.         $this->marquesManager $marquesManager;
  105.         $this->langs = ['fr''nl'];
  106.         $request Request::createFromGlobals();
  107.         if ($request->getHttpHost() == "espace-adherent.groupeall.com" || $request->getHttpHost() == "api.groupeall.com") {
  108.             $this->urlPhotosAdh $parameterBag->get('twicpics_domain_images_OPC') . 'adherent/';
  109.             $this->urlPhotosDefault $parameterBag->get('twicpics_domain_images_OPC') . 'webfactory/fitting_box/';
  110.             $this->urlPhotosPrivateUpload $parameterBag->get('twicpics_domain_images'). 'adherent/';
  111.         } elseif ($request->getHttpHost() == "espace-adherentpp.groupeall.com" || $request->getHttpHost() == "apipp.groupeall.com") {
  112.             $this->urlPhotosAdh $request->getSchemeAndHttpHost() . "/privateUploads/photos_adh_web/";
  113.             $this->urlPhotosDefault $request->getSchemeAndHttpHost() . "/build/images/webfactory/fitting_box/";
  114.             $this->urlPhotosPrivateUpload $request->getSchemeAndHttpHost() . "/privateUploads/photos_adh_web/";
  115.         } else {
  116.             $this->urlPhotosAdh $request->getSchemeAndHttpHost() . "/espace_adherent/public/privateUploads/photos_adh_web/";
  117.             $this->urlPhotosDefault $request->getSchemeAndHttpHost() . "/espace_adherent/public/build/images/webfactory/fitting_box/";
  118.             $this->urlPhotosPrivateUpload $request->getSchemeAndHttpHost() . "/espace_adherent/public/privateUploads/photos_adh_web/";
  119.         }
  120.     }
  121.     /**
  122.      * @Route("/magasin/{magasin}/widget/virtual_fitting", name="factory_api_widget_virtual_fitting")
  123.      * @param Request $request
  124.      * @param Magasin $magasin
  125.      * @return void
  126.      */
  127.     public function widgetCabineEssayage(Request $requestMagasin $magasin)
  128.     {
  129.         $listBrands $this->entityManager->getRepository(MagasinMarques::class)->findBy(['magasin' => $magasin]);
  130.         $tabListBrands $this->marquesManager->formatTabListBrandsApi($listBrands$magasin);
  131.         // ----------------------------------------- Gestion images fitting box -----------------------------------------------
  132.         $selectedFittingBoxImg $this->entityManager->getRepository(WebfactoryFittingBoxImg::class)->findOneBy(['adherent' => $magasin->getKAdherent()]);
  133.         $finalTab = [];
  134.         foreach ($this->langs as $lang) {
  135.             $finalTab[strtolower($lang)] = [
  136.                 "alt" => $this->translator->trans("Cabine d'essayage virtuelle", [], "messages"$lang),
  137.                 "title" => $this->translator->trans("Essayez votre monture en ligne", [], "messages"$lang),
  138.                 "button_text" => $this->translator->trans("Essayer maintenant", [], "messages"$lang),
  139.                 "brands_slides" => [
  140.                     'list' => $tabListBrands[strtolower($lang)]['list'],
  141.                     'total' => $tabListBrands[strtolower($lang)]['total']
  142.                 ]
  143.             ];
  144.             if ($selectedFittingBoxImg) {
  145.                 if ($selectedFittingBoxImg->getImageDefault()){
  146.                     $finalTab[strtolower($lang)]['image'] = $this->urlPhotosDefault $selectedFittingBoxImg->getImageWidget();
  147.                 } else {
  148.                     $finalTab[strtolower($lang)]['image'] = $this->urlPhotosPrivateUpload $magasin->getKAdherent() . "/"$selectedFittingBoxImg->getImageWidget();
  149.                 }
  150.             } else {
  151.                 $finalTab[strtolower($lang)]['image'] = $this->urlPhotosDefault "widget_fitting_box_2.png";
  152.             }
  153.         }
  154.         return new JsonResponse($finalTab);
  155.     }
  156.     /**
  157.      * @param Magasin $magasin
  158.      * @return JsonResponse
  159.      * @Route("/magasin/{magasin}/widget/hours", name="factory_api_widget_hours")
  160.      */
  161.     public function horaires(Magasin $magasin)
  162.     {
  163.         $datas = [
  164.             'fr' => $this->webfactoryManager->formatHoursForApi($magasin),
  165.             'nl' => $this->webfactoryManager->formatHoursForApi($magasin"nl")
  166.         ];
  167.         return new JsonResponse($datas);
  168.     }
  169.     /**
  170.      * @Route("/magasin/{magasin}/widget/store_presentation", name="factory_api_widget_store_presentation")
  171.      * @param Request $request
  172.      * @param Magasin $magasin
  173.      * @return JsonResponse
  174.      */
  175.     public function widgetPresentationMagasin(Request $requestMagasin $magasin)
  176.     {
  177.         if (!$request->query->has('page')) {
  178.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  179.         }
  180.         $page $request->query->get('page');
  181.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  182.         $pageCustomId $request->query->get('customPage');
  183.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  184.         $opc $this->webfactoryManager->getAffichageOpc($magasin->getKAdherent());
  185.         ($magasin->getKNIVEAUADH() == "LOL4G") ? $esv true $esv false;
  186.         $theme $config['offer']['theme']['name'];
  187.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'store_presentation']);
  188.         try {
  189.             $widgets $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  190.                 'magasin' => $magasin->getKAdherent(),
  191.                 'page' => $page->getIdentifier(),
  192.                 'theme' => $theme,
  193.                 'widget' => $widget,
  194.                 'pageCustom' => $pageCustomId
  195.             ]);
  196.         } catch (\Exception $e) {
  197.             return new JsonResponse(['status' => 500'error' => $e->getMessage()], 500);
  198.         }
  199.         $datas = [];
  200.         if (!empty($widgets)) {
  201.             foreach ($widgets as $widgetDetail) {
  202.                 $datas[strtolower($widgetDetail->getLang())] =
  203.                     [
  204.                         "title" => $widgetDetail->getTitle(),
  205.                         "baseline" => $widgetDetail->getText(),
  206.                         "button_text" => $widgetDetail->getButtonText(),
  207.                         "button_url" => $widgetDetail->getButtonUrl(),
  208.                         "perso_button_url" => $widgetDetail->getButtonUrlOther(),
  209.                         "hours" => $widgetDetail->getHours(),
  210.                         "images" => [
  211.                         ]
  212.                     ];
  213.                 if ($esv) {
  214.                     $datas[strtolower($widgetDetail->getLang())]['images'][] =
  215.                         [
  216.                             "src" => [
  217.                                 "mobile" => $this->cdnOpc "images/logo/Expert_Sante_Visuelle-ESV-noir-petit-FR.svg",
  218.                                 "tablette" => $this->cdnOpc "images/logo/Expert_Sante_Visuelle-ESV-noir-moyen-FR.svg",
  219.                                 "desktop" => $this->cdnOpc "images/logo/Expert_Sante_Visuelle-ESV-noir-grand-FR.svg"
  220.                             ],
  221.                             "alt" => "Logo du label Expert en santé visuelle",
  222.                             "title" => "Expert en santé visuelle"
  223.                         ];
  224.                 }
  225.                 if ($opc) {
  226.                     $datas[strtolower($widgetDetail->getLang())]['images'][] = [
  227.                         "src" => [
  228.                             "mobile" => $this->cdnOpc "images/logo/OPC-vert-petit.svg",
  229.                             "tablette" => $this->cdnOpc "images/logo/OPC-vert-moyen.svg",
  230.                             "desktop" => $this->cdnOpc "images/logo/OPC-vert-grand.svg",
  231.                         ],
  232.                         "alt" => "Logo Opticiens par conviction",
  233.                         "title" => "Opticiens par conviction"
  234.                     ];
  235.                 }
  236.             }
  237.             return new JsonResponse($datas);
  238.         } else {
  239.             return new JsonResponse(['status' => 400'error' => 'Aucun widget pour cette page'], 400);
  240.         }
  241.     }
  242.     /**
  243.      * @Route("/magasin/{magasin}/widget/contact", name="factory_api_widget_contact")
  244.      * @param Request $request
  245.      * @param Magasin $magasin
  246.      * @return void
  247.      */
  248.     public function widgetCoordonnees(Request $requestMagasin $magasin)
  249.     {
  250.         $social_medias $this->entityManager->getRepository(MagasinUrl::class)->findBy(['magasin' => $magasin]);
  251.         $socials = [];
  252.         $socialsNl = [];
  253.         if (!empty($social_medias)) {
  254.             foreach ($social_medias as $social_media) {
  255.                 if ($social_media->getType() == "facebook" && !is_null($social_media->getUrl())) {
  256.                     $currentSocial = [
  257.                         "url" => $this->forceHttps($social_media->getUrl()),
  258.                         "svg_name" => "facebook",
  259.                         "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/facebook.svg'),
  260.                         "type" => "facebook",
  261.                         "title" => "Voir notre compte Facebook"
  262.                     ];
  263.                     $socials[] = $currentSocial;
  264.                     $currentSocial['title'] = "Zie onze Facebook-account";
  265.                     $socialsNl $currentSocial;
  266.                 }
  267.                 if ($social_media->getType() == "twitter" && !is_null($social_media->getUrl())) {
  268.                     $currentSocial = [
  269.                         "url" => $this->forceHttps($social_media->getUrl()),
  270.                         "svg_name" => "twitter",
  271.                         "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/twitter.svg'),
  272.                         "type" => "twitter",
  273.                         "title" => "Voir notre compte Twitter"
  274.                     ];
  275.                     $socials[] = $currentSocial;
  276.                     $currentSocial['title'] = "Zie onze Twitter-account";
  277.                     $socialsNl $currentSocial;
  278.                 }
  279.                 if ($social_media->getType() == "instagram" && !is_null($social_media->getUrl())) {
  280.                     $currentSocial = [
  281.                         "url" => $this->forceHttps($social_media->getUrl()),
  282.                         "svg_name" => "instagram",
  283.                         "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/instagram.svg'),
  284.                         "type" => "instagram",
  285.                         "title" => "Voir notre profil Instagram"
  286.                     ];
  287.                     $socials[] = $currentSocial;
  288.                     $currentSocial['title'] = "Zie onze Instagram-account";
  289.                     $socialsNl $currentSocial;
  290.                 }
  291.                 if ($social_media->getType() == "tiktok" && !is_null($social_media->getUrl())) {
  292.                     $currentSocial = [
  293.                         "url" => $this->forceHttps($social_media->getUrl()),
  294.                         "svg_name" => "tiktok",
  295.                         "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/tiktok.svg'),
  296.                         "type" => "tiktok",
  297.                         "title" => "Voir notre profil TikTok"
  298.                     ];
  299.                     $socials[] = $currentSocial;
  300.                     $currentSocial['title'] = "Zie onze TikTok-account";
  301.                     $socialsNl $currentSocial;
  302.                 }
  303.             }
  304.         }
  305.         $ficheCoordonnees $this->entityManager->getRepository(MagasinCoordonnees::class)->findOneBy(
  306.             ['K_ADHERENT' => $magasin->getKAdherent(), 'TYPE' => 'MARKETING']);
  307.         if (empty($ficheCoordonnees)) {
  308.             $ficheCoordonnees $this->entityManager->getRepository(MagasinCoordonnees::class)->findOneBy(
  309.                 ['K_ADHERENT' => $magasin->getKAdherent(), 'TYPE' => 'MAGASIN']);
  310.             if (empty($ficheCoordonnees)) {
  311.                 $ficheCoordonnees $this->entityManager->getRepository(MagasinCoordonnees::class)->findOneBy(
  312.                     ['K_ADHERENT' => $magasin->getKAdherent(), 'TYPE' => 'SIEGE']);
  313.             }
  314.         }
  315.         // Mails pour "Envoyer un message"
  316.         $magasinContactsEmails $this->entityManager->getRepository(MagasinContact::class)->getSpecificContact($magasin'site_web_emails_contacts'truefalsetrue);
  317.         // Numéro de téléphone pour la prise de contact
  318.         $telDeContact $this->entityManager->getRepository(MagasinContact::class)->getSpecificContact($magasin'site_web_tel_contact');
  319.         $urlMagasin $this->entityManager->getRepository(MagasinUrl::class)->findOneBy(['magasin' => $magasin'type' => 'OPC/OZC']);
  320.         $urlRdv $this->entityManager->getRepository(MagasinUrl::class)->findOneBy(['magasin' => $magasin'type' => 'rdv']);
  321.         $contactsFr = [];
  322.         $contactsNl = [];
  323.         if (!is_null($ficheCoordonnees)) {
  324.             // Prise de rdv
  325.             preg_match("/(opticiens-oc.be\/nl\/*)|(:8082)/"$urlMagasin->getUrl(), $matches);
  326.             if (!empty($matches)) {
  327.                 $urlRdvOPC $urlMagasin->getUrl() . '/maak-een-afspraak';
  328.             } else {
  329.                 $urlRdvOPC $urlMagasin->getUrl() . '/prise-de-rdv';
  330.             }
  331.             $priseRdv = [
  332.                 "title" => "Prendre RDV",
  333.                 "svg_name" => "calendar-time",
  334.                 "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/calendar-week.svg'),
  335.                 "content" => null,
  336.                 "button_text" => "Prendre RDV",
  337.                 "link" => (!is_null($urlRdv)) ? $urlRdv->getUrl() : $urlRdvOPC,
  338.                 "target" => "_blank",
  339.                 "type" => "rdv",
  340.                 'rel' => 'nofollow'
  341.             ];
  342.             $contactsFr[] = $priseRdv;
  343.             $priseRdv['title'] = "Afspraak";
  344.             $priseRdv['button_text'] = "Lees meer";
  345.             $contactsNl[] = $priseRdv;
  346.             //Y aller
  347.             $destination urlencode(strtolower($ficheCoordonnees->getLib() . " " trim($ficheCoordonnees->getVOIENUM() . ' ' $ficheCoordonnees->getVOIETYPE() . ' ' $ficheCoordonnees->getVOIELIB()) . "," $ficheCoordonnees->getKCP() . "," $ficheCoordonnees->getKVILLE()));
  348.             $urlYAller "https://www.google.com/maps/dir/?api=1&destination=" $destination "&travelmode=driving";
  349.             $voieCplt = (!is_null($ficheCoordonnees->getVOIECPLT())) ? $ficheCoordonnees->getVOIECPLT() : "";
  350.             $content $ficheCoordonnees->getVOIENUM() . " " $voieCplt " " $ficheCoordonnees->getVOIETYPE() . " " $ficheCoordonnees->getVOIELIB() . "<br>" $ficheCoordonnees->getKCP() . " " $ficheCoordonnees->getKVILLE();
  351.             $yAller = [
  352.                 "title" => "S'y rendre",
  353.                 "svg_name" => "location",
  354.                 "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/geo-alt.svg'),
  355.                 "content" => $content,
  356.                 "button_text" => "S'y rendre",
  357.                 "link" => $urlYAller,
  358.                 "target" => "_blank",
  359.                 "type" => "location",
  360.                 "street" => $ficheCoordonnees->getVOIENUM() . " " $ficheCoordonnees->getVOIETYPE() . " " $ficheCoordonnees->getVOIELIB(),
  361.                 "zipcode" => $ficheCoordonnees->getKCP(),
  362.                 "city" => $ficheCoordonnees->getKVILLE(),
  363.                 "country" => $ficheCoordonnees->getKPAYS(),
  364.                 "lib" => $ficheCoordonnees->getLib()
  365.             ];
  366.             $contactsFr[] = $yAller;
  367.             $yAller['title'] = "Route";
  368.             $yAller['button_text'] = "Lees meer";
  369.             $contactsNl[] = $yAller;
  370.             // Appeler
  371.             if (!is_null($telDeContact)) {
  372.                 $indicatifs = ['+33''+32''+590''+596''+262''+377'];
  373.                 foreach ($indicatifs as $indicatif) {
  374.                     if (str_starts_with($telDeContact->getValue(), $indicatif)) {
  375.                         $telDeContactVisible substr($telDeContact->getValue(), strlen($indicatif));
  376.                         // clear
  377.                         $telDeContactVisible preg_replace('/\D/'''$telDeContactVisible);
  378.                         if ($telDeContactVisible[0] !== '0') {
  379.                             $telDeContactVisible '0' $telDeContactVisible;
  380.                         }
  381.                         break;
  382.                     }
  383.                 }
  384.                 // formatage espace entre 2
  385.                 $telDeContactVisible trim(chunk_split($telDeContactVisible2' '));
  386.                 $appeler = [
  387.                     "title" => "Appeler",
  388.                     "svg_name" => "phone",
  389.                     "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/telephone-fill.svg'),
  390.                     "content" => $telDeContactVisible,
  391.                     "button_text" => $telDeContactVisible,
  392.                     "link" => "tel:" str_replace(" """$telDeContact->getValue()),
  393.                     "target" => null,
  394.                     "type" => "phone"
  395.                 ];
  396.                 $contactsFr[] = $appeler;
  397.                 $appeler['title'] = "Bel";
  398.                 $appeler['button_text'] = $telDeContactVisible;
  399.                 $contactsNl[] = $appeler;
  400.             }
  401.             // Mail
  402.             if (!empty($magasinContactsEmails)) {
  403.                 $mails $magasinContactsEmails;
  404.                 $envoieMail = [
  405.                     "title" => "Envoyer un e-mail",
  406.                     "svg_name" => "mail",
  407.                     "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/send.svg'),
  408.                     "content" => $mails,
  409.                     "button_text" => "Nous contacter",
  410. //                    "link" => "mailto:" . rtrim($mails, ";"),
  411.                     "link" => "/contact",
  412.                     "target" => null,
  413.                     "type" => "mail"
  414.                 ];
  415.                 $contactsFr[] = $envoieMail;
  416.                 $envoieMail['title'] = "Stuur een e-mail";
  417.                 $envoieMail['button_text'] = "Neem contact op";
  418.                 $contactsNl[] = $envoieMail;
  419.             }
  420.         }
  421.         $contact_fr = [
  422.             "title" => "Contactez-nous",
  423.             "svg_name" => "clock",
  424.             "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/clock.svg'),
  425.             "contacts" => $contactsFr,
  426.             'socials' => $socials
  427.         ];
  428.         $contact_nl = [
  429.             "title" => "Neem contact op",
  430.             "svg_name" => "clock",
  431.             "icon" => "<svg width='18' height='20' viewBox='0 0 18 20'><path d='M15,2h0V0H13V2H5V0H3V2H3A3,3,0,0,0,0,5V17a3,3,0,0,0,3,3H15a3,3,0,0,0,3-3V5A3,3,0,0,0,15,2Zm1,14.83a1,1,0,0,1-1,1H3a1,1,0,0,1-1-1v-10a1,1,0,0,1,1-1H15a1,1,0,0,1,1,1Z'/></svg>",
  432.             "contacts" => $contactsNl,
  433.             'socials' => $socialsNl
  434.         ];
  435.         $datas = [
  436.             'fr' => $contact_fr,
  437.             'nl' => $contact_nl
  438.         ];
  439.         return new JsonResponse($datas);
  440.     }
  441.     /**
  442.      * @Route("/magasin/{magasin}/widget/social_networks", name="factory_api_widget_social_networks")
  443.      * @param Request $request
  444.      * @param Magasin $magasin
  445.      * @return void
  446.      */
  447.     public function widgetSocialNetwork(Request $requestMagasin $magasin)
  448.     {
  449.         $social_medias $this->entityManager->getRepository(MagasinUrl::class)->findBy(['magasin' => $magasin]);
  450.         $socials = [];
  451.         $socialsNl = [];
  452.         $allowTypes = ['facebook''twitter''instagram''youtube''linkedin''whatsapp''tiktok'];
  453.         if (!empty($social_medias)) {
  454.             foreach ($social_medias as $social_media) {
  455.                 if (in_array($social_media->getType(), $allowTypes) && !is_null($social_media->getUrl())) {
  456.                     $currentSocial = [
  457.                         "url" => $this->forceHttps($social_media->getUrl()),
  458.                         "svg_name" => strtolower($social_media->getType()),
  459.                         "icon" => file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/' strtolower($social_media->getType()) . '.svg'),
  460.                         "type" => strtolower($social_media->getType()),
  461.                         "title" => "Voir notre compte " ucfirst($social_media->getType()),
  462.                     ];
  463.                     $socials[] = $currentSocial;
  464.                     $currentSocial['title'] = "Zie onze " ucfirst($social_media->getType()) . "-account";
  465.                     $socialsNl[] = $currentSocial;
  466.                 }
  467.             }
  468.         }
  469.         $contact_fr = [
  470.             'socials' => $socials
  471.         ];
  472.         $contact_nl = [
  473.             'socials' => $socialsNl
  474.         ];
  475.         $datas = [
  476.             'fr' => $contact_fr,
  477.             'nl' => $contact_nl
  478.         ];
  479.         return new JsonResponse($datas);
  480.     }
  481.     /**
  482.      * @Route("/magasin/{magasin}/widget/brands", name="factory_api_widget_brands")
  483.      * @param Request $request
  484.      * @param Magasin $magasin
  485.      * @return void
  486.      */
  487.     public function widgetMarques(Request $requestMagasin $magasin)
  488.     {
  489.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  490.         $theme $config['offer']['theme']['name'];
  491.         $entityName "App\Entity\Webfactory\\Widget\\" $theme "\\Brands";
  492.         $widgets $this->entityManager->getRepository($entityName)->findBy(['magasin' => $magasin]);
  493.         $brands = [
  494.             'fr' => ['widget' => [], 'categories' => [], 'total' => 0],
  495.             'nl' => ['widget' => [], 'categories' => [], 'total' => 0]
  496.         ];
  497.         if (!empty($widgets)) {
  498.             foreach ($widgets as $widget) {
  499.                 $brands[strtolower($widget->getLang())] = [
  500.                     "widget" => [
  501.                         "title" => $widget->getTitle(),
  502.                         "description" => $widget->getDescription(),
  503.                         "image" => $this->urlPhotosAdh $magasin->getKAdherent() . '/' $widget->getImage(),
  504.                         "button" => $widget->getButton()
  505.                     ],
  506.                     "categories" => [],
  507.                     "total" => 0
  508.                 ];
  509.             }
  510.         }
  511.         return new JsonResponse($brands);
  512.     }
  513.     /**
  514.      * @Route("/magasin/{magasin}/widget/list-brands", name="factory_api_widget_list_marques")
  515.      * @param Request $request
  516.      * @param Magasin $magasin
  517.      * @return JsonResponse
  518.      */
  519.     public function widgetListMarques(Request $requestMagasin $magasin): JsonResponse
  520.     {
  521.         //     ?limit=9&page=0
  522.         $limit = ($request->query->has('limit')) ? intval($request->query->get('limit')) : 100;
  523.         $page = ($request->query->has('page')) ? intval($request->query->get('page')) : 1;
  524.         if ($page <= 1) {
  525.             $offset 0;
  526.         } else {
  527.             $offset $page $limit $limit;
  528.         }
  529.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  530.         $theme $config['offer']['theme']['name'];
  531.         $entityName "App\Entity\Webfactory\\Widget\\" $theme "\\Brands";
  532.         $widgets $this->entityManager->getRepository($entityName)->findBy(['magasin' => $magasin]);
  533.         $finalTab = [];
  534.         if (!empty($widgets)) {
  535.             foreach ($widgets as $widget) {
  536.                 $finalTab[strtolower($widget->getLang())] = [
  537.                     "title" => $widget->getTitle(),
  538.                     "description" => $widget->getDescription(),
  539.                     "bouton_text" => $widget->getButton(),
  540.                     "url" => (strtolower($widget->getLang()) == "nl") ? '/merken' '/marques',
  541.                     'list' => []
  542.                 ];
  543.                 $listBrands $widget->getListBrands();
  544.                 $criteria Criteria::create()->where(Criteria::expr()->in("id"array_slice($listBrands$offset$limit)));
  545.                 $magMarques $this->entityManager->getRepository(MagasinMarques::class)->matching($criteria)->getValues();
  546.                 $tabListBrands $this->marquesManager->formatTabListBrandsApi($magMarques);
  547.                 $finalTab[strtolower($widget->getLang())]['list'] = $tabListBrands[strtolower($widget->getLang())]['list'];
  548.             }
  549.         }
  550.         return new JsonResponse($finalTab);
  551.     }
  552.     /**
  553.      * @Route("/magasin/{magasin}/widget/deals", name="factory_api_widget_deals")
  554.      * @param Request $request
  555.      * @param Magasin $magasin
  556.      * @return JsonResponse
  557.      */
  558.     public function widgetDeals(Request $requestMagasin $magasin)
  559.     {
  560.         $date = new \DateTime('now');
  561.         $year $date->format('Y');
  562.         $previousYear $date->sub(new \DateInterval("P1Y"));
  563.         $prev_year $previousYear->format("Y");
  564.         $anneeLimitTraitement $year 2;
  565.         $offres_inscription $this->entityManager->getRepository(OffreInscription::class)->findBy(['adherent' => $magasin->getKAdherent(), 'tag' => [$year$prev_year]]);
  566.         $address $this->entityManager->getRepository(MagasinCoordonnees::class)->findOneBy([
  567.             'K_ADHERENT' => $magasin->getKAdherent(),
  568.             'TYPE' => 'MAGASIN'
  569.         ]);
  570.         if (empty($address)) {
  571.             $address $this->entityManager->getRepository(MagasinCoordonnees::class)->findOneBy(['K_ADHERENT' => $magasin->getKAdherent(), 'TYPE' => 'SIEGE']);
  572.         }
  573.         $details['deals'] = [];
  574.         if (!empty($offres_inscription)) {
  575.             foreach ($offres_inscription as $inscription) {
  576.                 if (substr($inscription->getTag(), 04) > $anneeLimitTraitement) {
  577.                     $list_insc json_decode($inscription->getOffres());
  578.                     foreach ($list_insc as $insc) {
  579.                         $offre $this->entityManager->getRepository(OffreWeb::class)->findOneBy(['code' => $insc]);
  580.                         $debut $offre->getDateDebut();
  581.                         $fin $offre->getDateFin();
  582.                         $tag substr($offre->getTag(), 04);
  583.                         if (date("Y-m-d h:m:s") >= $debut->format('Y-m-d h:m:s') && date("Y-m-d h:m:s") <= $fin->format('Y-m-d h:m:s')) {
  584.                             $infosOffre = [
  585.                                 "src" => $this->getParameter("twicpics_domain_images_OPC") . "offres-web/" $tag "/640x338/" $offre->getPays() . "/" $offre->getFileEmail(),
  586.                                 "alt" => $offre->getTexte(),
  587.                                 "title" => $offre->getTexte(),
  588.                                 "slug_title" => $offre->getName(),
  589.                                 "url" => $this->opcManager->getAdhOpcUrl($address),
  590.                                 "legals" => $offre->getMentions(),
  591.                                 "type" => $offre->getType() == 'P' 'headline' 'season',
  592.                                 "uid" => $offre->getTag() . $insc,
  593.                                 "year" => $offre->getTag(),
  594.                                 "seo" => [
  595.                                     "title" => ucfirst(strtolower($magasin->getLib())) . " - " $offre->getName(),
  596.                                     "description" => $offre->getTexte(),
  597.                                     "keywords" => ""
  598.                                 ],
  599.                                 'rel' => 'nofollow'
  600.                             ];
  601.                             if ($offre->getType() === "S") {
  602.                                 $details['current'][] = $infosOffre;
  603.                             } else {
  604.                                 $details['deals'][] = $infosOffre;
  605.                             }
  606.                         }
  607.                     }
  608.                 }
  609.             }
  610.         }
  611.         $dealsYear = [
  612.             "title" => "Découvrez nos offres",
  613.             "subtitle" => "valables toute l'année",
  614.             "button_text" => "Voir nos bons plans",
  615.             "button_url" => $this->opcManager->getAdhOpcUrl($address),
  616.             "deals" => $details['deals']
  617.         ];
  618.         $dealCurrent = [
  619.             "title" => "Découvrez notre offre",
  620.             "subtitle" => "du moment",
  621.             "button_text" => "Voir nos bons plans",
  622.             "button_url" => $this->opcManager->getAdhOpcUrl($address),
  623.             "deal" => (array_key_exists('current'$details)) ? $details['current'] : []
  624.         ];
  625.         $datas = [
  626.             'fr' => [
  627.                 'current' => (array_key_exists('current'$details)) ? $dealCurrent : [],
  628.                 'year' => (!empty($details['deals'])) ? $dealsYear : [],
  629.                 'slug' => "offres",
  630.                 'slug_translated' => 'deals',
  631.             ],
  632.             'nl' => [
  633.                 'current' => (array_key_exists('current'$details)) ? $dealCurrent : [],
  634.                 'year' => (!empty($details['deals'])) ? $dealsYear : [],
  635.                 'slug' => "deals",
  636.                 'slug_translated' => 'offres',
  637.             ]
  638.         ];
  639.         return new JsonResponse($datas);
  640.     }
  641.     /**
  642.      * @Route("/magasin/{magasin}/widget/teams", name="factory_api_widget_teams")
  643.      * @param Request $request
  644.      * @param Magasin $magasin
  645.      * @return void
  646.      */
  647.     public function widgetTeams(Request $requestMagasin $magasin)
  648.     {
  649.         $datas = [
  650.             'fr' => [],
  651.             'nl' => []
  652.         ];
  653.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  654.         $theme $config['offer']['theme']['name'];
  655.         $entityName "App\Entity\Webfactory\\Widget\\" $theme "\\Teams";
  656.         $widgetTeams $this->entityManager->getRepository($entityName)->findBy(['magasin' => $magasin->getKAdherent()]);
  657.         $magasinEquipe $this->entityManager->getRepository(MagasinEquipe::class)->findOneBy(['magasin' => $magasin->getKAdherent()]);
  658.         if (!empty($widgetTeams)) {
  659.             foreach ($widgetTeams as $widgetTeam) {
  660.                 $verbatim = [
  661.                     "quote" => "",
  662.                     "from" => ""
  663.                 ];
  664.                 if (!is_null($magasinEquipe)) {
  665.                     if (strtolower($widgetTeam->getLang()) === "fr") {
  666.                         $verbatim["quote"] = $magasinEquipe->getVerbatim();
  667.                         $verbatim["from"] = "L'équipe " ucfirst(strtolower($magasin->getLib()));
  668.                     } else {
  669.                         $verbatim["quote"] = $magasinEquipe->getVerbatimNl();
  670.                         $verbatim["from"] = "Het " ucfirst(strtolower($magasin->getLib())) . " team";
  671.                     }
  672.                 }
  673.                 $widget = [
  674.                     "title" => $widgetTeam->getEquipeTitre(),
  675.                     "description" => $widgetTeam->getEquipeDescription(),
  676.                     "button_text" => $widgetTeam->getButtonText(),
  677.                     "verbatim" => $verbatim
  678.                 ];
  679.                 $detail = [
  680.                     "image" => [
  681.                         [
  682.                             "media" => [
  683.                                 "mobile" => (!is_null($magasinEquipe)) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $magasinEquipe->getPhotoEquipe() : "",
  684.                                 "desktop" => (!is_null($magasinEquipe)) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $magasinEquipe->getPhotoEquipe() : "",
  685.                             ],
  686.                             "alt" => "",
  687.                             "title" => ""
  688.                         ]
  689.                     ],
  690.                     "title" => "",
  691.                     "description" => "",
  692.                     "seo" => [
  693.                         "title" => "",
  694.                         "description" => "",
  695.                         "keywords" => ""
  696.                     ]
  697.                 ];
  698.                 $teams = [];
  699.                 $arrayIdCollabo $widgetTeam->getEquipeList();
  700.                 $collaborateurs $this->entityManager->getRepository(MagasinCollaborateurs::class)->findByArrayId($arrayIdCollabo);
  701.                 foreach ($collaborateurs as $collaborateur) {
  702.                     $teams[] = [
  703.                         "image" => [
  704.                             "small" => (!is_null($collaborateur->getImage())) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $collaborateur->getImage() : $this->cdnOpc 'webfactory/default/' FactoryEnum::ProfileImage,
  705.                             "big" => (!is_null($collaborateur->getImage())) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $collaborateur->getImage() : $this->cdnOpc 'webfactory/default/' FactoryEnum::ProfileImage
  706.                         ],
  707.                         "alt" => $collaborateur->getImage(),
  708.                         "title" => $collaborateur->getImage(),
  709.                         "name" => $collaborateur->getLastName(),
  710.                         "firstname" => $collaborateur->getFirstName(),
  711.                         "job" => (strtolower($widgetTeam->getLang()) === "fr") ? $collaborateur->getJobs() : $collaborateur->getJobsNl(),
  712.                         "skills" => (strtolower($widgetTeam->getLang()) === "fr") ? $collaborateur->getSpecialties() : $collaborateur->getSpecialtiesNl(),
  713.                         "presentation" => (strtolower($widgetTeam->getLang()) === "fr") ? $collaborateur->getPresentation() : $collaborateur->getPresentationNl(),
  714.                         "verbatim" => (strtolower($widgetTeam->getLang()) === "fr") ? $collaborateur->getVerbatim() : $collaborateur->getVerbatimNl()
  715.                     ];
  716.                 }
  717.                 $team = [
  718.                     'widget' => $widget,
  719.                     "details" => $detail,
  720.                     "teams" => $teams
  721.                 ];
  722.                 (strtolower($widgetTeam->getLang()) === "fr") ? $datas['fr'][] = $team $datas['nl'][] = $team;
  723.             }
  724.         }
  725.         return new JsonResponse($datas);
  726.     }
  727.     /**
  728.      * @Route("/magasin/{magasin}/widget/crm_reviews", name="factory_api_widget_crm_reviews")
  729.      * @Route("/magasin/{magasin}/page/reviews_detail", name="factory_api_page_reviews_detail")
  730.      * @param Request $request
  731.      * @param Magasin $magasin
  732.      * @return void
  733.      * @throws \Exception
  734.      */
  735.     public function widgetCrmReviews(Request $requestMagasin $magasin)
  736.     {
  737.         $queryParams $request->query->all();
  738.         $limit = (!empty($queryParams && array_key_exists('limit'$queryParams))) ? intval($queryParams['limit']) : 3;
  739.         $offset = (!empty($queryParams && array_key_exists('offset'$queryParams))) ? intval($queryParams['offset']) : 0;
  740.         // Vérification si adhérent a le CRM ou des avis GMB
  741.         $CRM_infos $this->crmAccessManager->checkAccessCrm($magasin->getKAdherent(), null);
  742.         $avisGmb $magasin->isAvisGmbActive();
  743.         $data['statutAvisGMB'] = false;
  744.         $listAvis = [];
  745.         $noteAvis = [];
  746.         if ($avisGmb) {
  747.             $data['statutAvisGMB'] = true;
  748.         }
  749.         if ($magasin->getKAdherent() == "C9920") {
  750.             $CRM_infos["access"] = true;
  751.             $CRM_infos["avis_crm"] = true;
  752.         }
  753.         // Contrat CRM valide, a des avis et souhaite les afficher
  754.         if ($CRM_infos['access'] && $CRM_infos['avis_crm']) {
  755.             $query = (new QueryProgress("quest_ach_indiv"))
  756.                 ->where('K_QUEST''=''SAT')
  757.                 ->andWhere("K_ADHERENT"'=', ($magasin->getKAdherent() == "C9920") ? "C3571" $magasin->getKAdherent())
  758.                 ->orderBy('D_CREE''DESC')
  759.                 ->limit(05000);
  760.             $allAvis $this->rcuManager->findAvis($query);
  761.             foreach ($allAvis as &$data) {
  762.                 // Traitement du tableau QUEST_L
  763.                 $quest = [];
  764.                 if ($data['QUEST_L']) {
  765.                     foreach ($data['QUEST_L'] as $quest_l) {
  766.                         $quest[$quest_l["K_QUEST_L"]] = ['val' => $quest_l['VAL'], 'date' => $quest_l['D_CREE']];
  767.                     }
  768.                     $data['QUEST_L'] = $quest;
  769.                     // Gestion des variables réutilisables
  770.                     $commentaire = (isset($data['QUEST_L']['experience_opticien_commentaire']['val'])) ? addslashes($data['QUEST_L']['experience_opticien_commentaire']['val']) : "";
  771.                     $reponse = (isset($data['QUEST_L']['experience_opticien_commentaire_rep']['val'])) ? addslashes($data['QUEST_L']['experience_opticien_commentaire_rep']['val']) : "";
  772.                     $d_cree = new \DateTime($data['D_CREE']);
  773.                     $now = new \DateTime('2021-04-27');
  774.                     $autoPublicationDate = new \DateTime('2024-02-20');
  775.                     // Application des CGU le 27/04/2021
  776.                     // Avant le 27/04
  777.                     if ($d_cree->getTimestamp() < $now->getTimestamp()) {
  778.                         //On crée le tableau que si l'avis peut être publié
  779.                         if (isset($data['QUEST_L']['publication_avis']['val']) && $data['QUEST_L']['publication_avis']['val'] == && !isset($data['QUEST_L']['publication_OPC']['val'])) {
  780.                             $listAvis[] = [
  781.                                 "name" => $data['PRENOM'] . " " $data['NOM'][0],
  782.                                 "fr" => $commentaire,
  783.                                 "nl" => $commentaire,
  784.                                 "lang" => "fr",
  785.                                 "rating" => $data['QUEST_L']['experience_opticien']['val'],
  786.                                 "answer" => $reponse,
  787.                                 "date" => $data['D_CREE'],
  788.                                 "origin" => "Groupe All"
  789.                             ];
  790.                         }
  791.                     } else {
  792.                         // A partir du 20/02/2024 les avis sont publiés automatiquement
  793.                         //On crée le tableau que si l'avis peut être publié en acceptant les CGU
  794.                         if (
  795.                             (isset($data['QUEST_L']['cgu']['val']) &&
  796.                                 (isset($data['QUEST_L']['publication_avis']['val']) &&
  797.                                     $data['QUEST_L']['publication_avis']['val'] == "1") &&
  798.                                 ($data['QUEST_L']['cgu']['val'] == 'yes' || $data['QUEST_L']['cgu']['val'] == '1') &&
  799.                                 !isset($data['QUEST_L']['publication_OPC']['val']))
  800.                             || $d_cree->getTimestamp() >= $autoPublicationDate->getTimestamp()
  801.                         ) {
  802.                             $listAvis[] = [
  803.                                 "name" => $data['PRENOM'] . " " $data['NOM'][0],
  804.                                 "fr" => $commentaire,
  805.                                 "nl" => $commentaire,
  806.                                 "lang" => "fr",
  807.                                 "rating" => (int)$data['QUEST_L']['experience_opticien']['val'],
  808.                                 "answer" => $reponse,
  809.                                 "date" => $data['D_CREE'],
  810.                                 "origin" => "Groupe All"
  811.                             ];
  812.                         }
  813.                     }
  814.                 }
  815.             }
  816.         }
  817.         if (!empty($listAvis)) {
  818.             //Somme des notes de l'adhérent
  819.             $notes 0;
  820.             foreach ($listAvis as $k => $v) {
  821.                 $notes += $v['rating'];
  822.             }
  823.             $noteAvis['total'] = count($listAvis);
  824.             $noteAvis['note'] = floor($notes count($listAvis) * 10) / 10;
  825.             $noteAvis['detail']['five'] = $this->filtersReviewsHelper->countStarsReview($listAvis5);
  826.             $noteAvis['detail']['four'] = $this->filtersReviewsHelper->countStarsReview($listAvis4);
  827.             $noteAvis['detail']['three'] = $this->filtersReviewsHelper->countStarsReview($listAvis3);
  828.             $noteAvis['detail']['two'] = $this->filtersReviewsHelper->countStarsReview($listAvis2);
  829.             $noteAvis['detail']['one'] = $this->filtersReviewsHelper->countStarsReview($listAvis1);
  830.         }
  831.         $rating = [
  832.             "total_rating" => $noteAvis $noteAvis['total'] : null,
  833.             "average_rating" => $noteAvis $noteAvis['note'] : null,
  834.             'detailed_rating' => $noteAvis $noteAvis['detail'] : null,
  835.             "ratings" => $listAvis,
  836.             "limited_ratings" => $limit array_slice($listAvis$offset$limit) : null,
  837.             "image" => $this->cdnOpc "webfactory/pages/Details-avis.png",
  838.             "lang" => [
  839.                 "fr" => [
  840.                     "title" => "Découvrez",
  841.                     "subtitle" => "nos avis clients"
  842.                 ],
  843.                 "nl" => [
  844.                     "title" => "Ontdek",
  845.                     "subtitle" => "onze klantenbeoordelingen"
  846.                 ]
  847.             ]
  848.         ];
  849.         return new JsonResponse($rating);
  850.     }
  851.     /**
  852.      * @Route("/magasin/{magasin}/widget/crm_reviews_by_note", name="factory_api_widget_crm_reviews_by_note")
  853.      * @param Request $request
  854.      * @param Magasin $magasin
  855.      * @return void
  856.      * @throws \Exception
  857.      */
  858.     public function widgetCrmReviewsByNote(Request $requestMagasin $magasin)
  859.     {
  860.         $queryParams $request->query->all();
  861.         $note intval($queryParams['note']);
  862.         $limit = (!empty($queryParams && array_key_exists('limit'$queryParams))) ? intval($queryParams['limit']) : null;
  863.         $offset = (!empty($queryParams && array_key_exists('offset'$queryParams))) ? intval($queryParams['offset']) : 0;
  864.         // Vérification si adhérent a le CRM ou des avis GMB
  865.         $CRM_infos $this->crmAccessManager->checkAccessCrm($magasin->getKAdherent(), null);
  866.         $avisGmb $magasin->isAvisGmbActive();
  867.         $data['statutAvisGMB'] = false;
  868.         $listAvis = [];
  869.         $noteAvis = [];
  870.         if ($avisGmb) {
  871.             $data['statutAvisGMB'] = true;
  872.         }
  873.         if ($magasin->getKAdherent() == "C9920") {
  874.             $CRM_infos["access"] = true;
  875.             $CRM_infos["avis_crm"] = true;
  876.         }
  877.         // Contrat CRM valide, a des avis et souhaite les afficher
  878.         if ($CRM_infos['access'] && $CRM_infos['avis_crm']) {
  879.             $query = (new QueryProgress("quest_ach_indiv"))
  880.                 ->where('K_QUEST''=''SAT')
  881.                 ->andWhere("K_ADHERENT"'=', ($magasin->getKAdherent() == "C9920") ? "C3571" $magasin->getKAdherent())
  882.                 ->orderBy('D_CREE''DESC')
  883.                 ->limit(05000);
  884.             $allAvis $this->rcuManager->findAvis($query);
  885.             foreach ($allAvis as &$data) {
  886.                 // Traitement du tableau QUEST_L
  887.                 $quest = [];
  888.                 if ($data['QUEST_L']) {
  889.                     foreach ($data['QUEST_L'] as $quest_l) {
  890.                         $quest[$quest_l["K_QUEST_L"]] = ['val' => $quest_l['VAL'], 'date' => $quest_l['D_CREE']];
  891.                     }
  892.                     $data['QUEST_L'] = $quest;
  893.                     // Gestion des variables réutilisables
  894.                     $commentaire = (isset($data['QUEST_L']['experience_opticien_commentaire']['val'])) ? addslashes($data['QUEST_L']['experience_opticien_commentaire']['val']) : "";
  895.                     $d_cree = new \DateTime($data['D_CREE']);
  896.                     $now = new \DateTime('2021-04-27');
  897.                     $autoPublicationDate = new \DateTime('2024-02-20');
  898.                     // Application des CGU le 27/04/2021
  899.                     // Avant le 27/04
  900.                     if ($d_cree->getTimestamp() < $now->getTimestamp()) {
  901.                         //On crée le tableau que si l'avis peut être publié
  902.                         if (isset($data['QUEST_L']['publication_avis']['val']) && $data['QUEST_L']['publication_avis']['val'] == && !isset($data['QUEST_L']['publication_OPC']['val'])) {
  903.                             if ($note == $data['QUEST_L']['experience_opticien']['val']) {
  904.                                 $listAvis[] = [
  905.                                     "name" => $data['PRENOM'] . " " $data['NOM'][0],
  906.                                     "fr" => $commentaire,
  907.                                     "nl" => $commentaire,
  908.                                     "lang" => "fr",
  909.                                     "rating" => $data['QUEST_L']['experience_opticien']['val'],
  910.                                     "date" => $data['D_CREE'],
  911.                                     "origin" => "Groupe All"
  912.                                 ];
  913.                             }
  914.                         }
  915.                     } else {
  916.                         // A partir du 20/02/2024 les avis sont publiés automatiquement
  917.                         //On crée le tableau que si l'avis peut être publié en acceptant les CGU
  918.                         if (
  919.                             (isset($data['QUEST_L']['cgu']['val']) &&
  920.                                 (isset($data['QUEST_L']['publication_avis']['val']) &&
  921.                                     $data['QUEST_L']['publication_avis']['val'] == "1") &&
  922.                                 ($data['QUEST_L']['cgu']['val'] == 'yes' || $data['QUEST_L']['cgu']['val'] == '1') &&
  923.                                 !isset($data['QUEST_L']['publication_OPC']['val']))
  924.                             || $d_cree->getTimestamp() >= $autoPublicationDate->getTimestamp()
  925.                         ) {
  926.                             if ($note == $data['QUEST_L']['experience_opticien']['val']) {
  927.                                 $listAvis[] = [
  928.                                     "name" => $data['PRENOM'] . " " $data['NOM'][0],
  929.                                     "fr" => $commentaire,
  930.                                     "nl" => $commentaire,
  931.                                     "lang" => "fr",
  932.                                     "rating" => (int)$data['QUEST_L']['experience_opticien']['val'],
  933.                                     "date" => $data['D_CREE'],
  934.                                     "origin" => "Groupe All"
  935.                                 ];
  936.                             }
  937.                         }
  938.                     }
  939.                 }
  940.             }
  941.         }
  942.         $rating = [
  943.             "ratings" => $listAvis,
  944.             "limited_ratings" => $limit array_slice($listAvis$offset$limit) : null,
  945.             "nb_notes" => count($listAvis),
  946.             "lang" => [
  947.                 "fr" => [
  948.                     "title" => "Découvrez",
  949.                     "subtitle" => "Nos avis clients"
  950.                 ],
  951.                 "nl" => [
  952.                     "title" => "Ontdek",
  953.                     "subtitle" => "Onze klantenbeoordelingen"
  954.                 ]
  955.             ]
  956.         ];
  957.         return new JsonResponse($rating);
  958.     }
  959.     /**
  960.      * @Route("/magasin/{magasin}/widget/news", name="factory_api_widget_news")
  961.      * @param Request $request
  962.      * @param Magasin $magasin
  963.      * @return void
  964.      */
  965.     public function widgetNews(Request $requestMagasin $magasin)
  966.     {
  967.         $queryParams $request->query->all();
  968.         $limit = (!empty($queryParams && array_key_exists('limit'$queryParams))) ? intval($queryParams['limit']) : 4;
  969.         $page = (!empty($queryParams && array_key_exists('page'$queryParams))) ? intval($queryParams['page']) : 0;
  970.         $categoryiD = (!empty($queryParams && array_key_exists('category'$queryParams))) ? intval($queryParams['category']) : null;
  971.         $lang = (!empty($queryParams && array_key_exists('lang'$queryParams))) ? strtolower($queryParams['lang']) : 'fr';
  972.         $offset = ($page 1) ? ($page $limit $limit) : 0;
  973.         $articles = [];
  974.         if (!is_null($categoryiD) && $categoryiD != 0) {
  975.             $category $this->entityManager->getRepository(WebfactoryActualiteCategory::class)->findOneBy(['id' => $categoryiD]);
  976.             if (!is_null($category)) {
  977.                 $dataArticles $this->entityManager->getRepository(WebfactoryActualite::class)->paginateArticlesByCategory($magasin$offset$limit$category->getId(), $lang);
  978.             } else {
  979.                 return new JsonResponse('Catégorie inconnue');
  980.             }
  981.         } else {
  982.             $datas $this->entityManager->getRepository(WebfactoryActualite::class)->findBy(['adherent' => $magasin->getKAdherent(), 'active' => true], ['updated_at' => 'DESC'], $limit$offset);
  983.             $dataArticles['articles'] = $datas;
  984.         }
  985.         foreach ($dataArticles['articles'] as $article) {
  986.             foreach ($article->getWebfactoryActualiteContenus() as $contenu) {
  987.                 if ($contenu->getStatut() != "brouillon"
  988.                     && (
  989.                         (is_null($contenu->getDateDebutpublication()) && is_null($contenu->getDateFinPublication()))
  990.                         || ($contenu->getDateDebutpublication() <= new \DateTime('today'))
  991.                         || ($contenu->getDateDebutpublication() <= new \DateTime('today') && $contenu->getDateFinPublication() >= new \DateTime('today'))
  992.                     )
  993.                 ) {
  994.                     $categoryContenu $article->getActualiteCategory()?->getContenuByLang($lang);
  995.                     $articles[strtolower($contenu->getLang())][] = [
  996.                         "id" => $article->getId(),
  997.                         "slug" => $contenu->getSlug(),
  998.                         "title" => $contenu->getTitle(),
  999.                         "short_description" => html_entity_decode($contenu->getShortDescription()),
  1000.                         "description" => $contenu->getContent(),
  1001.                         "date" => $contenu->getDateDebutPublication() ? strtotime($contenu->getDateDebutPublication()->format('Y-m-d H:i:s')) : strtotime($contenu->getCreatedAt()->format('Y-m-d H:i:s')),
  1002.                         "author" => $article->getAuthor(),
  1003.                         "lang" => strtolower($contenu->getLang()),
  1004.                         "categories" => [
  1005.                             [
  1006.                                 "title" => ($categoryContenu) ? $categoryContenu->getName() : "",
  1007.                                 "id" => ($article->getActualiteCategory()) ? $article->getActualiteCategory()->getId() : "",
  1008.                                 'lang' => strtolower($contenu->getLang())
  1009.                             ]
  1010.                         ],
  1011.                         "src" => ($article->isLockCopie()) ? $this->cdnOpc "articlesPrerediges/" $contenu->getImage() : $this->cdnOpc 'adherent/' $article->getAdherent() . "/" $contenu->getImage()
  1012.                     ];
  1013.                 }
  1014.             }
  1015.         }
  1016.         $datas = [
  1017.             'fr' => [
  1018.                 "news" => (array_key_exists('fr'$articles)) ? $articles['fr'] : [],
  1019.                 "seo" => [
  1020.                     "title" => "",
  1021.                     "description" => "",
  1022.                     "keywords" => ""
  1023.                 ],
  1024.                 "total" => (array_key_exists('fr'$articles)) ? count($articles['fr']) : 0
  1025.             ],
  1026.             'nl' => [
  1027.                 "news" => (array_key_exists('nl'$articles)) ? $articles['nl'] : [],
  1028.                 "seo" => [
  1029.                     "title" => "",
  1030.                     "description" => "",
  1031.                     "keywords" => ""
  1032.                 ],
  1033.                 "total" => (array_key_exists('nl'$articles)) ? count($articles['nl']) : 0
  1034.             ]
  1035.         ];
  1036.         return new JsonResponse($datas);
  1037.     }
  1038.     /**
  1039.      * @Route("/magasin/{magasin}/widget/lastnews", name="factory_api_widget_lastnews")
  1040.      * @param Request $request
  1041.      * @param Magasin $magasin
  1042.      * @return void
  1043.      */
  1044.     public function widgetLastNews(Request $requestMagasin $magasin)
  1045.     {
  1046.         $limit 4;
  1047.         $articlesFr = [];
  1048.         $articlesNl = [];
  1049.         $articles $this->entityManager->getRepository(WebfactoryActualite::class)->findLastActu($magasin$limit);
  1050.         foreach ($articles as $article) {
  1051.             foreach ($article->getWebfactoryActualiteContenus() as $contenu) {
  1052.                 if ($contenu->getStatut() != "brouillon"
  1053.                     && (
  1054.                         (is_null($contenu->getDateDebutpublication()) && is_null($contenu->getDateFinPublication()))
  1055.                         || ($contenu->getDateDebutpublication() <= new \DateTime('today'))
  1056.                         || ($contenu->getDateDebutpublication() <= new \DateTime('today') && $contenu->getDateFinPublication() >= new \DateTime('today'))
  1057.                     )
  1058.                 ) {
  1059.                     $categoryContenu $article->getActualiteCategory()?->getContenuByLang($contenu->getLang());
  1060.                     $art = [
  1061.                         "id" => $article->getId(),
  1062.                         "slug" => $contenu->getSlug(),
  1063.                         "title" => $contenu->getTitle(),
  1064.                         "lang" => strtolower($contenu->getLang()),
  1065.                         "short_description" => html_entity_decode($contenu->getShortDescription()),
  1066.                         "date" => strtotime($contenu->getCreatedAt()->format('Y-m-d H:i:s')),
  1067.                         "author" => $article->getAuthor(),
  1068.                         "categories" => [
  1069.                             [
  1070.                                 "title" => ($categoryContenu) ? $categoryContenu->getName() : "",
  1071.                                 "id" => ($article->getActualiteCategory()) ? $article->getActualiteCategory()->getId() : "",
  1072.                                 'lang' => strtolower($contenu->getLang())
  1073.                             ]
  1074.                         ],
  1075.                         "src" => ($article->isLockCopie()) ? $this->cdnOpc "articlesPrerediges/" $contenu->getImage() : $this->urlPhotosAdh $article->getAdherent() . "/" $contenu->getImage()
  1076.                     ];
  1077.                     (strtolower($contenu->getLang()) === "fr") ? $articlesFr[] = $art $articlesNl[] = $art;
  1078.                 }
  1079.             }
  1080.         }
  1081.         $datas = [
  1082.             'fr' => [
  1083.                 "last_news" => $articlesFr
  1084.             ],
  1085.             'nl' => [
  1086.                 "last_news" => $articlesNl
  1087.             ],
  1088.         ];
  1089.         return new JsonResponse($datas);
  1090.     }
  1091.     /**
  1092.      * @Route("/magasin/{magasin}/widget/news/categories", name="factory_api_widget_categories")
  1093.      * @param Request $request
  1094.      * @param Magasin $magasin
  1095.      * @return JsonResponse
  1096.      */
  1097.     public function widgetCategories(Request $requestMagasin $magasin)
  1098.     {
  1099.         $categoriesFr = [];
  1100.         $categoriesNl = [];
  1101.         $nbTotalNews = ['fr' => 0'nl' => 0];
  1102.         $categoriesFrNl $this->entityManager->getRepository(WebfactoryActualiteCategory::class)->findBy(['adherent' => $magasin]);
  1103.         foreach ($categoriesFrNl as $categorie) {
  1104.             foreach ($categorie->getWebfactoryActualiteCategoryContenus() as $contenu) {
  1105.                 $categ = [
  1106.                     "name" => $contenu->getName(),
  1107.                     "id" => $categorie->getId(),
  1108.                     "slug" => $contenu->getSlug(),
  1109.                     "total" => count($categorie->getWebfactoryActualites()->toArray())
  1110.                     /*                    "lang" => $categorie->getLang(),
  1111.                                         'correspondance' => (!is_null($categorie->getCorrespondance())) ? $categorie->getCorrespondance()->getId() : null*/
  1112.                 ];
  1113.                 $nbTotalNews[strtolower($contenu->getLang())] += count($categorie->getWebfactoryActualites()->toArray());
  1114.                 (strtolower($contenu->getLang()) === "fr") ? $categoriesFr[] = $categ $categoriesNl[] = $categ;
  1115.             }
  1116.         }
  1117.         array_unshift($categoriesFr, ['name' => 'Toutes''id' => 0'slug' => 'toutes''total' => $nbTotalNews['fr']]);
  1118.         array_unshift($categoriesNl, ['name' => 'alle''id' => 0'slug' => 'alle''total' => $nbTotalNews['nl']]);
  1119.         $datas = [
  1120.             'fr' => [
  1121.                 "categories" => $categoriesFr
  1122.             ],
  1123.             'nl' => [
  1124.                 "categories" => $categoriesNl
  1125.             ],
  1126.         ];
  1127.         return new JsonResponse($datas);
  1128.     }
  1129.     /**
  1130.      * @Route("/magasin/{magasin}/widget/news/{slug}", name="factory_api_widget_news_detail")
  1131.      * @param Magasin $magasin
  1132.      * @param null $slug
  1133.      * @return void
  1134.      * @throws NonUniqueResultException
  1135.      */
  1136.     public function widgetNewsDetail(Magasin $magasin$slug null)
  1137.     {
  1138.         $article $this->entityManager->getRepository(WebfactoryActualite::class)->createQueryBuilder('a')
  1139.             ->join('a.webfactoryActualiteContenus''ac''ac.article')
  1140.             ->where('ac.slug = :slug')
  1141.             ->andWhere('a.adherent = :adherent')
  1142.             ->andWhere('ac.statut != :statut OR ac.statut IS NULL')
  1143.             ->setParameter('slug'$slug)
  1144.             ->setParameter('adherent'$magasin)
  1145.             ->setParameter('statut''brouillon')
  1146.             ->getQuery()->getOneOrNullResult();
  1147.         if (!is_null($article)) {
  1148.             foreach ($article->getWebfactoryActualiteContenus() as $contenu) {
  1149.                 $categoryContent $article->getActualiteCategory()?->getContenuByLang($contenu->getLang());
  1150.                 $news[strtolower($contenu->getLang())] = [
  1151.                     "id" => $article->getId(),
  1152.                     "slug" => $contenu->getSlug(),
  1153.                     "title" => $contenu->getTitle(),
  1154.                     "image" => [
  1155.                         "mobile" => ($article->isLockCopie()) ? $this->cdnOpc "articlesPrerediges/" $contenu->getImage() : $this->urlPhotosAdh $magasin->getKAdherent() . "/" $contenu->getImage(),
  1156.                         "desktop" => ($article->isLockCopie()) ? $this->cdnOpc "articlesPrerediges/" $contenu->getImage() : $this->urlPhotosAdh $magasin->getKAdherent() . "/" $contenu->getImage(),
  1157.                         "alt" => $contenu->getTitle(),
  1158.                         "title" => $contenu->getTitle()
  1159.                     ],
  1160.                     "description1" => $contenu->getContent(),
  1161.                     "description2" => "",
  1162.                     "date" => $contenu->getDateDebutPublication() ? $contenu->getDateDebutPublication()->format('Y-m-d H:i:s') : $contenu->getUpdatedAt()->format('Y-m-d H:i:s'),
  1163.                     "author" => $article->getAuthor(),
  1164.                     "author_job" => (strtolower(strtolower($contenu->getLang())) === "nl") ? "Het team van " $magasin->getLib() : "L'équipe de " $magasin->getLib(),
  1165.                     "lang" => strtolower($contenu->getLang()),
  1166.                     "categories" => [
  1167.                         [
  1168.                             "title" => (isset($categoryContent)) ? $categoryContent->getName() : "",
  1169.                             "id" => (isset($categoryContent)) ? $article->getActualiteCategory()->getId() : "",
  1170.                             'lang' => (isset($categoryContent)) ? strtolower($categoryContent->getLang()) : "",
  1171.                         ]
  1172.                     ],
  1173.                     "seo" => [
  1174.                         "title" => $contenu->getMetatitle(),
  1175.                         "description" => $contenu->getMetaDesc(),
  1176.                         "keywords" => $contenu->getMetaKeywords()
  1177.                     ]
  1178.                 ];
  1179.             }
  1180.             $datas = [
  1181.                 'fr' => (array_key_exists('fr'$news)) ? $news['fr'] : [],
  1182.                 'nl' => (array_key_exists('nl'$news)) ? $news['nl'] : []
  1183.             ];
  1184.             return new JsonResponse($datas);
  1185.         }
  1186.         return new JsonResponse('Article introuvable');
  1187.     }
  1188.     /**
  1189.      * @Route("/magasin/{magasin}/widget/banner", name="factory_api_widget_banner")
  1190.      * @param Request $request
  1191.      * @param Magasin $magasin
  1192.      * @return void
  1193.      */
  1194.     public function widgetAnnouncementBar(Request $requestMagasin $magasin)
  1195.     {
  1196.         $datas = [
  1197.             'fr' => [
  1198.                 'banner' => []
  1199.             ],
  1200.             'nl' => [
  1201.                 'banner' => []
  1202.             ],
  1203.         ];
  1204.         if (!is_null($magasin)) {
  1205.             $announcementBars $this->entityManager->getRepository(AnnouncementBar::class)->findBy(['magasin' => $magasin]);
  1206.             foreach ($announcementBars as $announcementBar) {
  1207.                 $options $announcementBar->getOptions()->toArray();
  1208.                 foreach ($options as $option) {
  1209.                     $banner = [];
  1210.                     switch ($option->getChoice()) {
  1211.                         case 'texte_libre':
  1212.                             $banner = [
  1213.                                 "type" => $option->getChoice(),
  1214.                                 "content" => $option->getContent(),
  1215.                                 "url" => $option->getUrl(),
  1216.                                 "target" => $option->getTarget(),
  1217.                                 "rating" => null,
  1218.                                 "author" => null
  1219.                             ];
  1220.                             break;
  1221.                         case 'rdv':
  1222.                             $urlRdv $this->entityManager->getRepository(MagasinUrl::class)->findOneBy(['magasin' => $magasin'type' => 'rdv']);
  1223.                             // Prise de rdv
  1224.                             $urlMagasin $this->entityManager->getRepository(MagasinUrl::class)->findOneBy(['magasin' => $magasin'type' => 'OPC/OZC']);
  1225.                             preg_match("/(opticiens-oc.be\/nl\/*)/"$urlMagasin->getUrl(), $matches);
  1226.                             if (!empty($matches)) {
  1227.                                 $slugrdv $urlMagasin->getUrl() . '/maak-een-afspraak';
  1228.                             } else {
  1229.                                 $slugrdv $urlMagasin->getUrl() . '/prise-de-rdv';
  1230.                             }
  1231.                             $urlRDV = (!is_null($urlRdv)) ? $urlRdv->getUrl() : $slugrdv;
  1232.                             $banner = [
  1233.                                 "type" => $option->getChoice(),
  1234.                                 "content" => $option->getContent(),
  1235.                                 "url" => $urlRDV,
  1236.                                 "target" => $option->getTarget(),
  1237.                                 "rating" => null,
  1238.                                 "author" => null,
  1239.                                 'rel' => 'nofollow'
  1240.                             ];
  1241.                             break;
  1242.                         case 'avis_CRM':
  1243.                             if (!is_null($option->getAvisCrm())) {
  1244.                                 $avis json_decode($option->getAvisCrm(), true);
  1245.                                 $content = [
  1246.                                     "date" => $avis['D_CREE'],
  1247.                                     "comment" => $avis['COMMENT']
  1248.                                 ];
  1249.                                 $banner = [
  1250.                                     "type" => $option->getChoice(),
  1251.                                     "content" => $content,
  1252.                                     "url" => null,
  1253.                                     "target" => $option->getTarget(),
  1254.                                     "rating" => $avis['NOTE'],
  1255.                                     "author" => $avis['AUTEUR']
  1256.                                 ];
  1257.                             }
  1258.                             break;
  1259.                         case 'offers':
  1260.                             $banner = [
  1261.                                 "type" => $option->getChoice(),
  1262.                                 "content" => json_decode($option->getOffreWeb()),
  1263.                                 "url" => null,
  1264.                                 "target" => $option->getTarget(),
  1265.                                 "rating" => null,
  1266.                                 "author" => null
  1267.                             ];
  1268.                             break;
  1269.                     }
  1270.                     if (strtolower($announcementBar->getLang()) === "fr") {
  1271.                         $datas['fr']['banner'][] = $banner;
  1272.                     } else {
  1273.                         $datas['nl']['banner'][] = $banner;
  1274.                     }
  1275.                 }
  1276.             }
  1277.         }
  1278.         return new JsonResponse($datas);
  1279.     }
  1280.     /**
  1281.      * @Route("/magasin/{magasin}/widget/stores", name="factory_api_widget_stores")
  1282.      * @param Request $request
  1283.      * @param Magasin $magasin
  1284.      * @return void
  1285.      */
  1286.     public function widgetStores(Request $requestMagasin $magasin)
  1287.     {
  1288.         $stores = [];
  1289.         $seoFr = [
  1290.             "title" => "",
  1291.             "description" => "",
  1292.             "keywords" => ""
  1293.         ];
  1294.         $seoNl $seoFr;
  1295.         $magasins $this->entityManager->getRepository(Magasin::class)->findBy(['adhMmStat' => $magasin->getAdhMmStat()]);
  1296.         foreach ($magasins as $magasin) {
  1297.             foreach ($magasin->getMagasinCoordonnees() as $adresse) {
  1298.                 if (strtoupper($adresse->getTYPE()) === "MAGASIN") {
  1299.                     $entityName "App\Entity\Webfactory\\Page\\Classique\\Store";
  1300.                     $pageMagasins $this->entityManager->getRepository($entityName)->findBy(['magasin' => $magasin->getKADHERENT()]);
  1301.                     foreach ($pageMagasins as $pageMagasin) {
  1302.                         if (strtolower($pageMagasin->getLang()) === "fr") {
  1303.                             $seoFr = [
  1304.                                 "title" => (empty($seo['title'])) ? $pageMagasin->getMetatitle() : $seo['title'],
  1305.                                 "description" => (empty($seo['description'])) ? $pageMagasin->getMetadescription() : $seo['description'],
  1306.                                 "keywords" => (empty($seo['keywords'])) ? $pageMagasin->getMetakeywords() : $seo['keywords']
  1307.                             ];
  1308.                         } else {
  1309.                             $seoNl = [
  1310.                                 "title" => (empty($seo['title'])) ? $pageMagasin->getMetatitle() : $seo['title'],
  1311.                                 "description" => (empty($seo['description'])) ? $pageMagasin->getMetadescription() : $seo['description'],
  1312.                                 "keywords" => (empty($seo['keywords'])) ? $pageMagasin->getMetakeywords() : $seo['keywords']
  1313.                             ];
  1314.                         }
  1315.                     }
  1316.                     $rue = ((!empty($adresse->getVOIENUM())) ? $adresse->getVOIENUM() . ' ' '') .
  1317.                         ((!empty($adresse->getVOIECPLT())) ? $adresse->getVOIECPLT() . ' ' '') .
  1318.                         ((!empty($adresse->getVOIETYPE())) ? $adresse->getVOIETYPE() . ' ' '') .
  1319.                         ((!empty($adresse->getVOIELIB())) ? $adresse->getVOIELIB() : '');
  1320.                     // Image
  1321.                     $imageMags $this->entityManager->getRepository(Image::class)->findOneBy([
  1322.                         'adherent' => $magasin->getKADHERENT(),
  1323.                         'profileDefault' => true
  1324.                     ]);
  1325.                     $stores[] = [
  1326.                         "name" => $adresse->getLIB(),
  1327.                         "address" => $rue,
  1328.                         "address_2" => null,
  1329.                         "postal_code" => $adresse->getKCP(),
  1330.                         "city" => $adresse->getKVILLE(),
  1331.                         "src" => $imageMags != null $this->urlPhotosAdh $adresse->getKAdherent() . "/" $imageMags->getName() : null,
  1332.                         "code" => $adresse->getKADHERENT(),
  1333.                         "hours" => $this->webfactoryManager->formatHoursForApi($magasin),
  1334.                     ];
  1335.                 }
  1336.             }
  1337.         }
  1338.         $datas = [
  1339.             'fr' => [
  1340.                 "stores" => $stores,
  1341.                 "seo" => $seoFr
  1342.             ],
  1343.             'nl' => [
  1344.                 "stores" => $stores,
  1345.                 "seo" => $seoNl
  1346.             ]
  1347.         ];
  1348.         return new JsonResponse($datas);
  1349.     }
  1350.     /**
  1351.      * @Route("/magasin/{magasin}/widget/more_about", name="factory_api_widget_more_about")
  1352.      * @param Request $request
  1353.      * @param Magasin $magasin
  1354.      * @return void
  1355.      * MULTIPAGE !
  1356.      */
  1357.     public function widgetMoreAbout(Request $requestMagasin $magasin)
  1358.     {
  1359.         if (!$request->query->has('page')) {
  1360.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1361.         }
  1362.         $page $request->query->get('page');
  1363.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1364.         $pageCustomId $request->query->get('customPage');
  1365.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1366.         $theme $config['offer']['theme']['name'];
  1367.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'more_about']);
  1368.         $widgets $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1369.             'magasin' => $magasin->getKAdherent(),
  1370.             'page' => $page->getIdentifier(),
  1371.             'theme' => $theme,
  1372.             'widget' => $widget,
  1373.             'pageCustom' => $pageCustomId
  1374.         ]);
  1375.         $datas = ['fr' => [], 'nl' => []];
  1376.         if (!empty($widgets)) {
  1377.             foreach ($widgets as $widgetDetails) {
  1378.                 $datas[strtolower($widgetDetails->getLang())] = [
  1379.                     'title' => $widgetDetails->getText(),
  1380.                     'link' => $widgetDetails->getLink(),
  1381.                     "perso_link" => $widgetDetails->getLinkOther(),
  1382.                     'image' => $this->urlPhotosAdh $magasin->getKAdherent() . "/" $widgetDetails->getImage(),
  1383.                     'target' => '_blank',
  1384.                     "button" => $this->translator->trans("En savoir plus", [], 'messages'$widgetDetails->getLang())
  1385.                 ];
  1386.             }
  1387.             return new JsonResponse($datas);
  1388.         } else {
  1389.             return new JsonResponse(['status' => 400'error' => 'Aucun widget pour cette page'], 400);
  1390.         }
  1391.     }
  1392.     /**
  1393.      * @Route("/magasin/{magasin}/widget/custom_text", name="factory_api_widget_custom_text")
  1394.      * @param Request $request
  1395.      * @param Magasin $magasin
  1396.      * @return void
  1397.      * MULTIPAGE !
  1398.      */
  1399.     public function widgetCustomText(Request $requestMagasin $magasin)
  1400.     {
  1401.         if (!$request->query->has('page')) {
  1402.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1403.         }
  1404.         $page $request->query->get('page');
  1405.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1406.         $pageCustomId $request->query->get('customPage');
  1407.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1408.         $theme $config['offer']['theme']['name'];
  1409.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'custom_text']);
  1410.         $widgetDetails $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1411.             'magasin' => $magasin->getKAdherent(),
  1412.             'page' => $page->getIdentifier(),
  1413.             'theme' => $theme,
  1414.             'widget' => $widget,
  1415.             'pageCustom' => $pageCustomId
  1416.         ]);
  1417.         $datas['fr']['content'] = [];
  1418.         $datas['nl']['content'] = [];
  1419.         if (!empty($widgetDetails)) {
  1420.             foreach ($widgetDetails as $widgetDetail) {
  1421.                 $datas[strtolower($widgetDetail->getLang())]['content'] = $widgetDetail->getContent();
  1422.             }
  1423.         }
  1424.         return new JsonResponse($datas);
  1425.     }
  1426.     /**
  1427.      * @Route("/magasin/{magasin}/widget/gallery", name="factory_api_widget_gallery")
  1428.      * @param Request $request
  1429.      * @param Magasin $magasin
  1430.      * @return void
  1431.      * MULTIPAGE
  1432.      */
  1433.     public function widgetGallery(Request $requestMagasin $magasin)
  1434.     {
  1435.         if (!$request->query->has('page')) {
  1436.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1437.         }
  1438.         $page $request->query->get('page');
  1439.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1440.         $pageCustomId $request->query->get('customPage');
  1441.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1442.         $theme $config['offer']['theme']['name'];
  1443.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'gallery']);
  1444.         $widgetDetails $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1445.             'magasin' => $magasin->getKAdherent(),
  1446.             'page' => $page->getIdentifier(),
  1447.             'theme' => $theme,
  1448.             'widget' => $widget,
  1449.             'pageCustom' => $pageCustomId
  1450.         ]);
  1451.         $datas['fr']['images'] = [];
  1452.         $datas['nl']['images'] = [];
  1453.         if (!empty($widgetDetails)) {
  1454.             foreach ($widgetDetails as $widgetDetail) {
  1455.                 if (!empty($widgetDetail->getImages()->toArray())) {
  1456.                     $images $widgetDetail->getImages()->toArray();
  1457.                     foreach ($images as $image) {
  1458.                         if (intval($image->getWidth()) > intval($image->getHeight())) {
  1459.                             $orientation "landscape";
  1460.                         } else {
  1461.                             $orientation "portrait";
  1462.                         }
  1463.                         $datas[strtolower($widgetDetail->getLang())]['images'][] = [
  1464.                             "media" => [
  1465.                                 "mobile" => $this->urlPhotosAdh $magasin->getKAdherent() . "/" $image->getName(),
  1466.                                 "desktop" => $this->urlPhotosAdh $magasin->getKAdherent() . "/" $image->getName(),
  1467.                             ],
  1468.                             "alt" => $image->getAlt(),
  1469.                             "title" => str_replace("." $image->getExtension(), ""$image->getName()),
  1470.                             'orientation' => $orientation,
  1471.                         ];
  1472.                     }
  1473.                     $datas[strtolower($widgetDetail->getLang())]['affichage'] = $widgetDetail->getTypeAffichagePhotos();
  1474.                     $datas[strtolower($widgetDetail->getLang())]['slider_slide_to_show'] = $widgetDetail->getSliderSlideToShow();
  1475.                 }
  1476.             }
  1477.         }
  1478.         return new JsonResponse($datas);
  1479.     }
  1480.     /**
  1481.      * @Route("/magasin/{magasin}/widget/esv", name="factory_api_widget_esv")
  1482.      * @param Request $request
  1483.      * @param Magasin $magasin
  1484.      * @return void
  1485.      */
  1486.     public function widgetESV(Request $requestMagasin $magasin)
  1487.     {
  1488.         if ($magasin->getKNIVEAUADH() === "LOL4G") {
  1489.             $esv = [
  1490.                 'fr' => [
  1491.                     "title" => "Expert santé visuelle",
  1492.                     "blocks" => [
  1493.                         [
  1494.                             "title" => "Experts santé visuelle qui sont-ils ?",
  1495.                             "svg_name" => "bullseye",
  1496.                             "icon" => file_get_contents($this->getParameter("images_directory") . "/icons/bxs-bullseye.svg.svg"),
  1497.                             "button_text" => "En savoir plus",
  1498.                             "link" => "https://www.opticiensparconviction.fr/les-experts-en-sante-visuelle",
  1499.                             "target" => "_blank",
  1500.                             'rel' => 'nofollow'
  1501.                         ],
  1502.                         [
  1503.                             "title" => "Ce qu’il faut savoir<br />Prix, qualité...",
  1504.                             "svg_name" => "purchase-tag",
  1505.                             "icon" => file_get_contents($this->getParameter("images_directory") . "/icons/bxs-purchase-tag.svg.svg"),
  1506.                             "button_text" => "En savoir plus",
  1507.                             "link" => "https://www.expertsantevisuelle.com/prix-qualite-remboursement/payer-le-bon-prix",
  1508.                             "target" => "_blank",
  1509.                             'rel' => 'nofollow'
  1510.                         ],
  1511.                         [
  1512.                             "title" => "Clins d’oeil, infos, astuces, conseils...",
  1513.                             "svg_name" => "info-circle",
  1514.                             "icon" => file_get_contents($this->getParameter("images_directory") . "/icons/bxs-info-circle.svg.svg"),
  1515.                             "button_text" => "En savoir plus",
  1516.                             "link" => "https://www.expertsantevisuelle.com/clin-oeil",
  1517.                             "target" => "_blank",
  1518.                             'rel' => 'nofollow'
  1519.                         ]
  1520.                     ]
  1521.                 ],
  1522.                 'nl' => []
  1523.             ];
  1524.             return new JsonResponse($esv);
  1525.         } else {
  1526.             return new JsonResponse(['status' => 400'error' => 'Adhérent non ESV'], 400);
  1527.         }
  1528.     }
  1529.     /**
  1530.      * @Route("/magasin/{magasin}/widget/services_specialties", name="factory_api_widget_services_specialties")
  1531.      * @param Request $request
  1532.      * @param Magasin $magasin
  1533.      * @return void
  1534.      */
  1535.     public function widgetServicesEtSpecialities(Request $requestMagasin $magasin)
  1536.     {
  1537.         $services $this->entityManager->getRepository(SiteWebService::class)->findBy(['kAdh' => $magasin], ['sort' => 'ASC']);
  1538.         $specialites $this->entityManager->getRepository(SiteWebSpecialite::class)->findBy(['kAdh' => $magasin], ['sort' => 'ASC']);
  1539.         $datas = [];
  1540.         $datas['fr']['widgets']['services_specialties'][] = [
  1541.             'subtitle' => "Notre expertise à votre service",
  1542.             'subdescription' => "Dans notre magasin, nous mettons à votre disposition une palette de services et de spécialités afin de vous garantir une expérience unique."
  1543.         ];
  1544.         $datas['nl']['widgets']['services_specialties'][] = [
  1545.             'subtitle' => "Onze expertise tot uw dienst",
  1546.             'subdescription' => "In onze winkel bieden wij een waaier van diensten en specialiteiten aan om een unieke ervaring te garanderen."
  1547.         ];
  1548.         foreach ($services as $serv) {
  1549.             $datas['fr']['widgets']['services_specialties']['services'][] = [
  1550.                 "name" => $serv->getIdService()->getName(),
  1551.                 "svg_name" => $serv->getIdService()->getSvg(),
  1552.                 'icon' => (!is_null($serv->getIdService()->getSvg())) ? file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/' $serv->getIdService()->getSvg()) : ""
  1553.             ];
  1554.             $datas['nl']['widgets']['services_specialties']['services'][] = [
  1555.                 "name" => $this->translator->trans($serv->getIdService()->getName(), [], 'messages''nl'),
  1556.                 "svg_name" => $serv->getIdService()->getSvg(),
  1557.                 'icon' => (!is_null($serv->getIdService()->getSvg())) ? file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/' $serv->getIdService()->getSvg()) : ""
  1558.             ];
  1559.         }
  1560.         foreach ($specialites as $spec) {
  1561.             $datas['fr']['widgets']['services_specialties']['specialites'][] = [
  1562.                 "name" => $spec->getIdSpecialite()->getName(),
  1563.                 "svg_name" => $spec->getIdSpecialite()->getSvg(),
  1564.                 'icon' => (!is_null($spec->getIdSpecialite()->getSvg())) ? file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/' $spec->getIdSpecialite()->getSvg() . ".svg") : ""
  1565.             ];
  1566.             $datas['nl']['widgets']['services_specialties']['specialites'][] = [
  1567.                 "name" => $this->translator->trans($spec->getIdSpecialite()->getName(), [], 'messages''nl'),
  1568.                 "svg_name" => $spec->getIdSpecialite()->getSvg(),
  1569.                 'icon' => (!is_null($spec->getIdSpecialite()->getSvg())) ? file_get_contents($this->getParameter("images_directory") . '/webfactory/svg/' $spec->getIdSpecialite()->getSvg() . ".svg") : ""
  1570.             ];
  1571.         }
  1572.         return new JsonResponse($datas);
  1573.     }
  1574.     /**
  1575.      * @Route("/magasin/{magasin}/widget/verbatim", name="factory_api_widget_verbatim")
  1576.      * @param Request $request
  1577.      * @param Magasin $magasin
  1578.      * @return void
  1579.      * MULTIPAGE !
  1580.      */
  1581.     public function widgetVerbatim(Request $requestMagasin $magasin)
  1582.     {
  1583.         if (!$request->query->has('page')) {
  1584.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1585.         }
  1586.         $page $request->query->get('page');
  1587.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1588.         $pageCustomId $request->query->get('customPage');
  1589.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1590.         $theme $config['offer']['theme']['name'];
  1591.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'verbatim']);
  1592.         $widgets $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1593.             'magasin' => $magasin->getKAdherent(),
  1594.             'page' => $page->getIdentifier(),
  1595.             'theme' => $theme,
  1596.             'widget' => $widget,
  1597.             'pageCustom' => $pageCustomId
  1598.         ]);
  1599.         $datas = [];
  1600.         foreach ($widgets as $widget) {
  1601.             $datas[strtolower($widget->getLang())][] = [
  1602.                 'quote' => $widget->getConviction(),
  1603.                 'from' => $widget->getAuthor()
  1604.             ];
  1605.         }
  1606.         return new JsonResponse($datas);
  1607.     }
  1608.     /**
  1609.      * @Route("/magasin/{magasin}/widget/promote", name="factory_api_widget_promote")
  1610.      * @param Request $request
  1611.      * @param Magasin $magasin
  1612.      * @return JsonResponse
  1613.      * MULTIPAGE !
  1614.      */
  1615.     public function widgetPromote(Request $requestMagasin $magasin)
  1616.     {
  1617.         if (!$request->query->has('page')) {
  1618.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1619.         }
  1620.         $page $request->query->get('page');
  1621.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1622.         $pageCustomId $request->query->get('customPage');
  1623.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1624.         $theme $config['offer']['theme']['name'];
  1625.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'promote']);
  1626.         $widgets $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1627.             'magasin' => $magasin->getKAdherent(),
  1628.             'page' => $page->getIdentifier(),
  1629.             'theme' => $theme,
  1630.             'widget' => $widget,
  1631.             'pageCustom' => $pageCustomId
  1632.         ]);
  1633.         $datas = [];
  1634.         if (!empty($widgets)) {
  1635.             foreach ($widgets as $widgetDetail) {
  1636.                 $datas[strtolower($widgetDetail->getLang())] = [
  1637.                     "first" => [
  1638.                         "title" => $widgetDetail->getDiscoveryTitle1(),
  1639.                         "button_text" => $widgetDetail->getDiscoveryBtnText1(),
  1640.                         "link" => $widgetDetail->getDiscoveryBtnUrl1(),
  1641.                         "perso_link" => $widgetDetail->getDiscoveryBtnUrlOther1(),
  1642.                         "images" => [
  1643.                             "image" => (!is_null($widgetDetail->getDiscoveryImg1())) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $widgetDetail->getDiscoveryImg1() : null,
  1644.                             "alt" => (!is_null($widgetDetail->getDiscoveryImg1())) ? "Image de présentation" null,
  1645.                             "title" => (!is_null($widgetDetail->getDiscoveryImg1())) ? "Image de présentation" null
  1646.                         ]
  1647.                     ],
  1648.                     "second" => [
  1649.                         "title" => $widgetDetail->getDiscoveryTitle2(),
  1650.                         "button_text" => $widgetDetail->getDiscoveryBtnText2(),
  1651.                         "link" => $widgetDetail->getDiscoveryBtnUrl2(),
  1652.                         "perso_link" => $widgetDetail->getDiscoveryBtnUrlOther2(),
  1653.                         "images" => [
  1654.                             "image" => (!is_null($widgetDetail->getDiscoveryImg2())) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $widgetDetail->getDiscoveryImg2() : null,
  1655.                             "alt" => (!is_null($widgetDetail->getDiscoveryImg2())) ? "Image de présentation" null,
  1656.                             "title" => (!is_null($widgetDetail->getDiscoveryImg2())) ? "Image de présentation" null
  1657.                         ]
  1658.                     ]
  1659.                 ];
  1660.             }
  1661.             return new JsonResponse($datas);
  1662.         } else {
  1663.             return new JsonResponse(['status' => 400'error' => 'Aucun widget pour cette page'], 400);
  1664.         }
  1665.     }
  1666.     /**
  1667.      * @Route("/magasin/{magasin}/widget/notification", name="factory_api_widget_notification")
  1668.      * @param Request $request
  1669.      * @param Magasin $magasin
  1670.      * @return void
  1671.      * MULTIPAGE
  1672.      */
  1673.     public function widgetNotification(Request $requestMagasin $magasin)
  1674.     {
  1675.         if (!$request->query->has('page')) {
  1676.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1677.         }
  1678.         $page $request->query->get('page');
  1679.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1680.         $pageCustomId $request->query->get('customPage');
  1681.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1682.         $theme $config['offer']['theme']['name'];
  1683.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'notification']);
  1684.         $widgetDetails $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1685.             'magasin' => $magasin->getKAdherent(),
  1686.             'page' => $page->getIdentifier(),
  1687.             'theme' => $theme,
  1688.             'widget' => $widget,
  1689.             'pageCustom' => $pageCustomId
  1690.         ]);
  1691.         $datas['fr'] = [];
  1692.         $datas['nl'] = [];
  1693.         if (!empty($widgetDetails)) {
  1694.             foreach ($widgetDetails as $widgetDetail) {
  1695.                 $datas[strtolower($widgetDetail->getLang())]['content'] = $widgetDetail->getContent();
  1696.                 $datas[strtolower($widgetDetail->getLang())]['start_date'] = $widgetDetail->getStartDate();
  1697.                 $datas[strtolower($widgetDetail->getLang())]['end_date'] = $widgetDetail->getEndDate();
  1698.                 $datas[strtolower($widgetDetail->getLang())]['uuid'] = base64_encode(uniqid($widgetDetail->getMagasin() . $widgetDetail->getId() . $widgetDetail->getUpdatedAt()?->format('Y-m-d')));
  1699.             }
  1700.         }
  1701.         return new JsonResponse($datas);
  1702.     }
  1703.     /**
  1704.      * @Route("/magasin/{magasin}/custom_css_js", name="factory_api_custom_css_js")
  1705.      * @param Request $request
  1706.      * @param Magasin $magasin
  1707.      * @return JsonResponse
  1708.      */
  1709.     public function customCssJs(Request $requestMagasin $magasin): JsonResponse
  1710.     {
  1711.         $custom $this->entityManager->getRepository(CustomCssJs::class)->findOneBy(['magasin' => $magasin->getKAdherent(), 'active' => 1]);
  1712.         $datas = [];
  1713.         if ($custom) {
  1714.             $datas = [
  1715.                 'css' => $custom->getContentCss(),
  1716.                 'js' => $custom->getContentJs()
  1717.             ];
  1718.         } else {
  1719.             return new JsonResponse(['status' => 400'error' => 'Aucun code css/js actif'], 400);
  1720.         }
  1721.         return new JsonResponse($datas200);
  1722.     }
  1723.     /**
  1724.      * @Route("/magasin/{magasin}/seo_ville/{ville}", name="factory_api_seo_villes")
  1725.      * @Route("/magasin/{magasin}/seo_ville/{ville}", name="factory_api_page_seo_ville_detail")
  1726.      * @param Request $request
  1727.      * @param Magasin $magasin
  1728.      * @return JsonResponse
  1729.      */
  1730.     public function apiSeoVilleDetail(Request $requestMagasin $magasin$ville null): JsonResponse
  1731.     {
  1732.         $arrayLangues = ['fr''nl'];
  1733.         $datas = [];
  1734.         if (is_null($ville)) {
  1735.             foreach ($arrayLangues as $langue) {
  1736.                 $findCities $this->entityManager->getRepository(SeoVilles::class)->createQueryBuilder('ville''ville.name')
  1737.                     ->select('ville.name, contenu.langue')
  1738.                     ->join(SeoVillesContenus::class, "contenu""WITH"'contenu.ville = ville.id')
  1739.                     ->where('ville.magasin = :magasin')
  1740.                     ->andWhere('contenu.langue = :langue')
  1741.                     ->setParameters(['magasin' => $magasin->getKAdherent(), 'langue' => $langue])
  1742.                     ->getQuery()->getResult();
  1743.                 foreach ($findCities as $city) {
  1744.                     $datas[$city['name']][$langue] = [
  1745.                         'name' => $city['name']
  1746.                     ];
  1747.                 }
  1748.             }
  1749.         } else {
  1750.             foreach ($arrayLangues as $langue) {
  1751.                 $findCity $this->entityManager->getRepository(SeoVilles::class)->createQueryBuilder('ville''ville.name')
  1752.                     ->select('ville.name,contenu.intro, contenu.text, contenu.metatitle, contenu.metadesc,contenu.image, contenu.langue')
  1753.                     ->join(SeoVillesContenus::class, "contenu""WITH"'contenu.ville = ville.id')
  1754.                     ->where('ville.magasin = :magasin')
  1755.                     ->andWhere('contenu.langue = :langue')
  1756.                     ->andWhere('ville.name = :ville')
  1757.                     ->setParameters(['magasin' => $magasin->getKAdherent(), 'langue' => $langue'ville' => strtoupper($ville)])
  1758.                     ->getQuery()->getOneOrNullResult();
  1759.                 if ($findCity) {
  1760.                     $datas[$langue]['name'] = $findCity['name'];
  1761.                     $datas[$langue]['intro'] = $findCity['intro'];
  1762.                     $datas[$langue]['text'] = $findCity['text'];
  1763.                     $datas[$langue]['metatitle'] = $findCity['metatitle'];
  1764.                     $datas[$langue]['metadesc'] = $findCity['metadesc'];
  1765.                     $datas[$langue]['image'] = ($findCity['image']) ? $this->urlPhotosAdh $magasin->getKAdherent() . "/" $findCity['image'] : null;
  1766.                     $datas[$langue]['enseigne'] = $magasin->getLib();
  1767.                 }
  1768.             }
  1769.         }
  1770.         if ($datas) {
  1771.             return new JsonResponse($datas200);
  1772.         } else {
  1773.             return new JsonResponse(['status' => 400'error' => 'Aucune ville'], 400);
  1774.         }
  1775.     }
  1776.     /**
  1777.      * @Route("/magasin/{magasin}/widget/faq", name="factory_api_widget_faq")
  1778.      * @param Request $request
  1779.      * @param Magasin $magasin
  1780.      * @return void
  1781.      * MULTIPAGE
  1782.      */
  1783.     public
  1784.     function widgetFaq(Request $requestMagasin $magasin)
  1785.     {
  1786.         if (!$request->query->has('page')) {
  1787.             return new JsonResponse(['status' => 400'error' => 'Paramètre page manquant'], 400);
  1788.         }
  1789.         $page $request->query->get('page');
  1790.         $page $this->entityManager->getRepository(WebfactoryPage::class)->findOneBy(['id' => $page]);
  1791.         $pageCustomId $request->query->get('customPage');
  1792.         $config $this->webfactoryManager->getFactoryConfig($magasin->getKAdherent());
  1793.         $theme $config['offer']['theme']['name'];
  1794.         $widget $this->entityManager->getRepository(WebfactoryWidget::class)->findOneBy(['identifier' => 'faq']);
  1795.         $widgetDetails $this->entityManager->getRepository(WidgetAbstract::class)->findBy([
  1796.             'magasin' => $magasin->getKAdherent(),
  1797.             'page' => $page->getIdentifier(),
  1798.             'theme' => $theme,
  1799.             'widget' => $widget,
  1800.             'pageCustom' => $pageCustomId
  1801.         ]);
  1802.         $datas['fr'] = [];
  1803.         $datas['nl'] = [];
  1804.         if (!empty($widgetDetails)) {
  1805.             foreach ($widgetDetails as $widgetDetail) {
  1806.                 foreach ($widgetDetail->getFaqContenus() as $key => $question) {
  1807.                     $datas[strtolower($widgetDetail->getLang())][$widgetDetail->getTitre()][$key]['question'] = $question->getQuestion();
  1808.                     $datas[strtolower($widgetDetail->getLang())][$widgetDetail->getTitre()][$key]['reponse'] = $question->getReponse();
  1809.                     $datas[strtolower($widgetDetail->getLang())][$widgetDetail->getTitre()][$key]['created_at'] = $question->getCreatedAt();
  1810.                     $datas[strtolower($widgetDetail->getLang())][$widgetDetail->getTitre()][$key]['updated_at'] = $question->getUpdatedAt();
  1811.                 }
  1812.             }
  1813.         }
  1814.         return new JsonResponse($datas);
  1815.     }
  1816.     /**
  1817.      * @Route("/magasin/{magasin}/image_partner", name="factory_api_image_partner")
  1818.      * @param Request $request
  1819.      * @param Magasin $magasin
  1820.      * @return JsonResponse
  1821.      */
  1822.     public function apiImagesPartners(Magasin $magasin): JsonResponse
  1823.     {
  1824.         $datas['fr'] = [];
  1825.         $datas['nl'] = [];
  1826.         $listImages $this->entityManager->getRepository(ImagePartner::class)->findBy(['magasin' => $magasin]);
  1827.         foreach ($listImages as $image) {
  1828.             $datas[strtolower($image->getLang())][] = [
  1829.                 'image' => $this->urlPhotosAdh $magasin->getKAdherent() . '/' $image->getImage(),
  1830.                 'slot' => $image->getSlot(),
  1831.             ];
  1832.         }
  1833.         return new JsonResponse($datas ?? null$datas 200 400);
  1834.     }
  1835.     private
  1836.     function translateHoursNL($day)
  1837.     {
  1838.         if (isset($day['morning']['hours']) && is_string($day['morning']['hours'])) {
  1839.             $day['morning']['hours'] = str_replace("h""u"$day['morning']['hours']);
  1840.         }
  1841.         if (isset($day['afternoon']['hours']) && is_string($day['afternoon']['hours'])) {
  1842.             $day['afternoon']['hours'] = str_replace("h""u"$day['afternoon']['hours']);
  1843.         }
  1844.         return $day;
  1845.     }
  1846.     private
  1847.     function forceHttps($url)
  1848.     {
  1849.         // Search the pattern
  1850.         if (!preg_match("~^(?:f|ht)tps?://~i"$url)) {
  1851.             // If not exist then add http
  1852.             $url "https://" $url;
  1853.         }
  1854.         // Return the URL
  1855.         return $url;
  1856.     }
  1857. }