src/Service/WSCMS.php line 195

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use Symfony\Component\HttpFoundation\RequestStack;
  4. use Symfony\Component\HttpFoundation\Session\SessionInterface as Session;
  5. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  6. class WSCMS
  7. {
  8.     public function __construct(Generale $generaleAuthorizationCheckerInterface $authorizationCheckerSession $sessionRequestStack $requestStack)
  9.     {
  10.         $this->webService = [$generale'WebService'];
  11.         $this->authorizationChecker $authorizationChecker;
  12.         $this->session $session;
  13.         $this->requestStack $requestStack;
  14.     }
  15.     public function Pays()
  16.     {
  17.         return call_user_func($this->webService'CMS''Pays', [], $this->requestStack->getCurrentRequest()->getLocale());
  18.     }
  19.     public function GroupePays()
  20.     {
  21.         return call_user_func($this->webService'CMS''GroupePays', [], $this->requestStack->getCurrentRequest()->getLocale());
  22.     }
  23.     public function Company()
  24.     {
  25.         return call_user_func($this->webService'CMS''Company', [], $this->requestStack->getCurrentRequest()->getLocale());
  26.     }
  27.     public function FlightClass()
  28.     {
  29.         return call_user_func($this->webService'CMS''FlightClass', [], $this->requestStack->getCurrentRequest()->getLocale());
  30.     }
  31.     public
  32.     function Ville()
  33.     {
  34.         if ($_SERVER['ENABLED_HOTEL_STAY_WORLDWIDE'] == 'true') return ['Villes' => []];
  35.         $villes call_user_func($this->webService'CMS''Ville', [], $this->requestStack->getCurrentRequest()->getLocale());
  36.         if ($_SERVER['ACCEPT_SEARCH_ALL_CITIES'] == 'true')
  37.             $villes['Villes'] = array_merge([['id' => 'all''ville' => 'tous''name' => 'Tous les hôtels''destination' => 'Tunis''pays' => 'tn''type' => 'v''image' => '']], $villes['Villes']);
  38.         return $villes;
  39.     }
  40.     public function Hotel(bool $appartement false,  $checkFiltre true)
  41.     {
  42.         // Sortie immédiate si le module hôtel monde est activé
  43.         if ($_SERVER['ENABLED_HOTEL_STAY_WORLDWIDE'] === 'true') {
  44.             return ['Hotels' => []];
  45.         }
  46.         // Détermination du mode B2B
  47.         $rolesB2B = ['ROLE_CLIENT_B2B''ROLE_CLIENT_B2B_OR_AMICALE'];
  48.         $isB2B in_array($_SERVER['APP_ACCESS_CONTROL'] ?? ''$rolesB2Btrue)
  49.             || in_array($_SERVER['APP_SECOND_ACCESS_CONTROL'] ?? ''$rolesB2Btrue);
  50.         // Récupération des hôtels
  51.         $hotels call_user_func(
  52.             $this->webService,
  53.             'CMS',
  54.             'Hotel',
  55.             [],
  56.             $this->requestStack->getCurrentRequest()->getLocale()
  57.         );
  58.         // Filtrage des hôtels
  59.         $hotels['Hotels'] = array_values(array_filter($hotels['Hotels'] ?? [], function ($h) use ($appartement$isB2B$checkFiltre) {
  60.             // Filtre appartement
  61.             if (isset($h['appartement']) and $h['appartement'] != $appartement) {
  62.                 return false;
  63.             }
  64.             // Filtre B2B / B2C
  65.             if ($checkFiltre) {
  66.                 return $isB2B ? !empty($h['filtreB2B']) : !empty($h['filtreB2C']);
  67.             }
  68.             return true;
  69.         }));
  70.         return $hotels;
  71.     }
  72.     public
  73.     function Hotel0($appartement false$checkB2B true)
  74.     {
  75.         if ($_SERVER['ENABLED_HOTEL_STAY_WORLDWIDE'] == 'true') return ['Hotels' => []];
  76.         $isB2B = (in_array($_SERVER['APP_ACCESS_CONTROL'], ['ROLE_CLIENT_B2B''ROLE_CLIENT_B2B_OR_AMICALE']) or
  77.             in_array($_SERVER['APP_SECOND_ACCESS_CONTROL'], ['ROLE_CLIENT_B2B''ROLE_CLIENT_B2B_OR_AMICALE']));
  78.         $hotels call_user_func($this->webService'CMS''Hotel', [], $this->requestStack->getCurrentRequest()->getLocale());
  79.         $hotels['Hotels'] = array_values(array_filter($hotels['Hotels'], function ($h) use ($appartement,$checkB2B,$isB2B) {
  80.             return (!isset($h['appartement']) or $h['appartement'] == $appartement) and !$checkB2B or $h['filtreB2B'];
  81.         }));
  82.         return $hotels;
  83.     }
  84.     public
  85.     function HotelEtiquette()
  86.     {
  87.         return call_user_func($this->webService'CMS''HotelEtiquette', [], date('dmY'));
  88.     }
  89.     public
  90.     function ReferentielsDemandeDeGroupe()
  91.     {
  92.         return call_user_func($this->webService'CMS''ReferentielsDemandeDeGroupe', [], $this->requestStack->getCurrentRequest()->getLocale());
  93.     }
  94.     public
  95.     function HotelsEquivalent()
  96.     {
  97.         return call_user_func($this->webService'CMS''HotelEquivalent', [], $this->requestStack->getCurrentRequest()->getLocale());
  98.     }
  99.     public
  100.     function GroupeVillesHotels()
  101.     {
  102.         return call_user_func($this->webService'CMS''GroupeVillesHotels', [], $this->requestStack->getCurrentRequest()->getLocale());
  103.     }
  104.     public
  105.     function BlocBootstrap()
  106.     {
  107.         return call_user_func($this->webService'CMS''BlocBootstrap', [], $this->requestStack->getCurrentRequest()->getLocale());
  108.     }
  109.     public
  110.     function Article()
  111.     {
  112.         return call_user_func($this->webService'CMS''Article', [], $this->requestStack->getCurrentRequest()->getLocale());
  113.     }
  114.     public
  115.     function BlocHtml()
  116.     {
  117.         return call_user_func($this->webService'CMS''BlocHtml', [], $this->requestStack->getCurrentRequest()->getLocale());
  118.     }
  119.     public
  120.     function Partenaire()
  121.     {
  122.         return call_user_func($this->webService'CMS''Partenaire', [], $this->requestStack->getCurrentRequest()->getLocale());
  123.     }
  124.     public
  125.     function LienElement()
  126.     {
  127.         return call_user_func($this->webService'CMS''LienElement', [], $this->requestStack->getCurrentRequest()->getLocale());
  128.     }
  129.     public
  130.     function Slider()
  131.     {
  132.         $sliders call_user_func($this->webService'CMS''Slider', [], $this->requestStack->getCurrentRequest()->getLocale());
  133.         foreach (['desktop''mobile'] as $device) {
  134.             $sliders['Sliders'][$device] = array_filter($sliders['Sliders'][$device], 'self::filtreSlider');
  135.             if (count($sliders['Sliders'][$device]) == 1)
  136.                 $sliders['Sliders'][$device][] = current($sliders['Sliders'][$device]);
  137.         }
  138.         return $sliders;
  139.     }
  140.     function filtreSlider($item)
  141.     {
  142.         $todays = new \DateTime("now");
  143.         return $todays >= new \DateTime($item['dateDebutAffichage']) and $todays <= new \DateTime($item['dateFinAffichage']);
  144.     }
  145.     public
  146.     function Element()
  147.     {
  148.         return call_user_func($this->webService'CMS''Element', [], $this->requestStack->getCurrentRequest()->getLocale());
  149.     }
  150.     public
  151.     function Agence()
  152.     {
  153.         $agence call_user_func($this->webService'CMS''Agence', [], $this->requestStack->getCurrentRequest()->getLocale());
  154.         if ($amicale $this->session->get('amicale'))
  155.             if (isset($amicale['configs']['SHOW_CONTACT_INFO_INSTEAD_OF_AGENCY']) and strtoupper($amicale['configs']['SHOW_CONTACT_INFO_INSTEAD_OF_AGENCY']) == 'TRUE')
  156.                 $agence['Agence'] = array_replace($agence['Agence'], ['adresse' => $amicale['adresse'], 'tel1' => $amicale['tel'], 'tel2' => null'fax' => $amicale['fax'], 'contactEmail' => $amicale['email']]);
  157.         $this->session->set('agence'$agence);
  158.         return $agence;
  159.     }
  160.     public
  161.     function Amicale()
  162.     {
  163.         return call_user_func($this->webService'CMS''InfosAmicale', [], $this->requestStack->getCurrentRequest()->getHost());
  164.     }
  165.     public
  166.     function PointVente($params)
  167.     {
  168.         return call_user_func($this->webService'CMS''PointVente'$params$this->requestStack->getCurrentRequest()->getLocale());
  169.     }
  170.     public
  171.     function NewsLetter($params)
  172.     {
  173.         return call_user_func($this->webService'CMS''NewsLetter'$params);
  174.     }
  175.     public
  176.     function ModePayement($params)
  177.     {
  178.         return call_user_func($this->webService'CMS''ModePayement'$params);
  179.     }
  180.     public
  181.     function ConfigurationPayement()
  182.     {
  183.         return call_user_func($this->webService'CMS''ConfigurationPayement', [], $this->requestStack->getCurrentRequest()->getLocale());
  184.     }
  185.     public
  186.     function Referencement()
  187.     {
  188.         return ['Referencement' => []];
  189.         #return call_user_func($this->webService, 'CMS', 'Referencement', [], $this->requestStack->getCurrentRequest()->getLocale());
  190.     }
  191.     public
  192.     function ReferencementRoute()
  193.     {
  194.         return call_user_func($this->webService'CMS''ReferencementRoute', [], $this->requestStack->getCurrentRequest()->getLocale());
  195.     }
  196.     public
  197.     function ArticlesElement()
  198.     {
  199.         return call_user_func($this->webService'CMS''ArticlesElement', [], $this->requestStack->getCurrentRequest()->getLocale());
  200.     }
  201.     public
  202.     function ConfigFrontOffice()
  203.     {
  204.         //https://domaine-back/admin/config/frontoffice/configuration-front-office/config?default-config
  205.         $defaultConfig '{"SEO":{"ROBOTSTXT":"","SITEMAPXML":""},"VOYAGE":{"BLOCS_DETAILS":1,"BLOC_CARNET":1,"TEXT_SELECT_PERIODES":"libelle","MODELE_OMRA_PERSONNALISE":"modele-voyage-organise","ADD_SELECT_PACK":"non","TYPE_CHAMP_PERIODE":"select","JOINDER_PASSPORT":"non","TRI_RESULTAT":"prix-asc","BLOC_THEMES_VO":"afficher-theme","INTERVALLE_PAGINATION":"10-30-50-100default30","INPUT_MATRICULE_TARIFS_DISPO":"non","INPUT_REFERENCE_INTERNE_TARIFS_DISPO":"non","ADD_FORM_ROOM_PAX_DETAILS_OMRA":"non","OMRA_ALLOW_ROOM_ADDITION":"non"},"SPA":{"TRI_RESULTAT":"prix-asc","INTERVALLE_PAGINATION":"10-30-50-100default10"},"HOTEL":{"ALLOW_PRINT_PROFORMA_INVOICE":"non","ALLOW_DIRECT_RESERVATION_CANCELLATION":"non","DETAILS_BLOC_ALBUMS":1,"DETAILS_VERSION_FILTRE":1,"LOADING_LIST":"classique","BLOC_CHAMBRE_TARIFS":"pension-room","BLOC_CHAMBRE_TARIFS_MOBILE":"pension-room","TYPE_INPUT_CHAMBRE":"select","TYPE_INPUT_ARRANGEMENT":"select","MODELE_SELECT_VILLE_HOTEL":"typeahead","MODELE_SELECT_VILLE_HOTEL_MOBILE":"typeahead","SEARCH_RECOMMENDED":"Hammamet","INFO_SELECT_CHAMBRE":"sur-select-chambre","COND_ANNUL_TARIF_DISPO":"sous-occupations-chambres","COND_ANNUL_TARIF_DISPO_MOBILE":"sous-occupations-chambres","DEFAULT_OPEN_BLOC_CHAMBRE_TARIFS":"close","DESCRIPTION_BLOC_HOTEL":"icons","TRI_RESULTAT":"prix-asc","BLOC_FILTRE":1,"BLOC_AFFINER":["arrangements","etoiles","price","chambres","tags","zone","disponible","enfantGratuit","promo","rembourssable","recommander"],"INPUT_OCCUPATIONS":"popup","INTERVALLE_PAGINATION":"10-30-50-100default10","MAX_ADULTE":"10","MAX_ENFANT":"4","MIN_AGE_ENFANT":"2","MAX_AGE_ENFANT":"14","VIEW_PAY_AT_HOTEL":"non","EDIT_PAY_AT_HOTEL":"non","DETAILS_BEFORE_TARIFS_DISPO":"non","INPUT_MATRICULE_TARIFS_DISPO":"non","CACHER_FORM_CLIENT_B2B_TARIFS_DISPO":"oui","INPUT_REFERENCE_INTERNE_TARIFS_DISPO":"non","DISPLAY_ONLY_CANCELLATION_DEADLINE_OR_NON_REFUNDABLE":"non","VIEW_CALENDRA":"non","DISPLAY_PRICE_HALF_DOUBLE":"non","CHECK_IMG_RECOMMANDED":false},"VOL":{"MODELE_ELEMENT_BILLET":"modele1","SEARCH_DEPARTURE_RECOMMENDED":"A\u00e9roport Houari Boumediene","SEARCH_ARRIVAL_RECOMMENDED":"A\u00e9roport d\u0027Istanbul","INTERVALLE_PAGINATION":"10-25-50-100default10","LOADING_LIST":"classique","TRI_RESULTAT":"prix-asc","BLOC_AFFINER":["escales","avion","price","classe","compagnieAerienne","aeorportDepart","aeorportArrivee","heureDepart","heureArrivee","bagage"],"JOINDER_PASSPORT":"non","HIDE_INFOS_CLIENT":"non","HIDE_INFOS_PASSAGERS":"non","HIDE_TARIF_DISPO":"non","PAYS_DEFAULT_TARIF_DISPO":"","PASSENGER_DEFAULT_BIRTHDAY_TARIF_DISPO":"","CLIENT_DEFAULT_VILLE_TARIF_DISPO":"","CLIENT_DEFAULT_ADRESSE_TARIF_DISPO":"","CLIENT_DEFAULT_TYPE_TEL_TARIF_DISPO":"M"},"GENERALE":{"RECAPTCHA_FORM":"non","NUMEROTATION_TITLE_FORM":"non","STYLESHEETS":"","COUPON_REDUCTION":"non","CONFIG_MAQUETTE":0}}';
  206.         $configs call_user_func($this->webService'CMS''ConfigFrontOffice', [], $this->requestStack->getCurrentRequest()->getLocale());
  207.         if (isset($configs['ConfigFrontOffice']['SEO']['ROBOTSTXT']) and $configs['ConfigFrontOffice']['SEO']['ROBOTSTXT'] != '')
  208.             file_put_contents('robots.txt'$configs['ConfigFrontOffice']['SEO']['ROBOTSTXT']);
  209.         if (isset($configs['ConfigFrontOffice']['SEO']['SITEMAPXML']) and $configs['ConfigFrontOffice']['SEO']['SITEMAPXML'] != '')
  210.             file_put_contents('sitemap.xml'$configs['ConfigFrontOffice']['SEO']['SITEMAPXML']);
  211.         /*if (!is_array($configs))
  212.             $configs['ConfigFrontOffice'] = json_decode($defaultConfig, true);
  213.         else*/
  214.         foreach (json_decode($defaultConfigtrue) as $key => $config)
  215.             foreach ($config as $_key => $item)
  216.                 if (!isset($configs['ConfigFrontOffice'][$key][$_key]))
  217.                     $configs['ConfigFrontOffice'][$key][$_key] = $item;
  218.         return $configs;
  219.     }
  220.     public
  221.     function ReseauxSociaux()
  222.     {
  223.         return call_user_func($this->webService'CMS''ReseauxSociaux', [], $this->requestStack->getCurrentRequest()->getLocale());
  224.     }
  225.     public
  226.     function Devise()
  227.     {
  228.         return call_user_func($this->webService'CMS''Devise', [], $this->requestStack->getCurrentRequest()->getLocale());
  229.     }
  230.     public
  231.     function SendMailLibre($params)
  232.     {
  233.         return call_user_func($this->webService'CMS''SendMailLibre'$params);
  234.     }
  235.     public
  236.     function SendEmailConfirmationInscrire($params)
  237.     {
  238.         return call_user_func($this->webService'CMS''SendEmailConfirmationInscrire'$params);
  239.     }
  240.     public
  241.     function CouponReduction($params)
  242.     {
  243.         return call_user_func($this->webService'CMS''CouponReduction'$params);
  244.     }
  245.     public
  246.     function ConditionVente()
  247.     {
  248.         return call_user_func($this->webService'CMS''ConditionVente', [], $this->requestStack->getCurrentRequest()->getLocale());
  249.     }
  250.     public
  251.     function Gallery()
  252.     {
  253.         return call_user_func($this->webService'CMS''Gallery', [], $this->requestStack->getCurrentRequest()->getLocale());
  254.     }
  255.     public function TopDestinations()
  256.     {
  257.         return call_user_func($this->webService'CMS''TopDestinations', [], $this->requestStack->getCurrentRequest()->getLocale());
  258.     }
  259.     public
  260.     function ContactPerso()
  261.     {
  262.         return call_user_func($this->webService'OldSHT''getcontactPerso', [], $this->requestStack->getCurrentRequest()->getLocale());
  263.     }
  264. }