src/Aviatur/SearchBundle/Controller/CarController.php line 17

Open in your IDE?
  1. <?php
  2. namespace Aviatur\SearchBundle\Controller;
  3. use Aviatur\AgencyBundle\Entity\Agency;
  4. use Aviatur\EditionBundle\Entity\HomePromo;
  5. use Aviatur\EditionBundle\Entity\HomePromoList;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. use Aviatur\TwigBundle\Services\TwigFolder;
  10. use Aviatur\CarBundle\Services\SearchCarCookie;
  11. class CarController extends AbstractController
  12. {
  13.     public function indexAction(RequestStack $requestStackManagerRegistry $registrySearchCarCookie $searchCarCookieTwigFolder $twigFolder)
  14.     {
  15.         $em $registry->getManager();
  16.         $session $requestStack->getSession();
  17.         $cookieLastSearch $searchCarCookie->searchCarCookie();
  18.         $agencyId $session->get('agencyId');
  19.         $agency $em->getRepository(Agency::class)->find($agencyId);
  20.         $promoType '';
  21.         $promoTypeMain '-main';
  22.         $promoTypeRecommendations '-recommendations';
  23.         $promoTypeFaq '-faq';
  24.         if ($session->has('whitemark') === true) {
  25.             $promoType '_' $session->get('whitemark');
  26.         }
  27.         $agenciesExcluded = ['Aviatur S.A.S.''Aviatur S.A.S. Metasearch''Aval''Aviacaribbean''Aviatur - WorldPay''Aviatur Carnaval BAQ MB''Aviatur Colombia''Aviatur Colombia EN''Aviatur Colombia ES''Aviatur Ecoturismo''Aviatur Kioskos''Aviatur Metasearch Mexico''Aviatur Mexico''Aviatur Mexico QA''Aviatur Mobile''Aviatur PinBus''Aviatur - Pruebas''BabyMarket''Buceo Colombia''Cielos Abiertos''Corona Aviatur''Directo a la Playa''Experiencias Jet-Set''Great Vibes''Landing visa''Lufthansa City Center''Megatours''Octopus Agents''Octopus Marcas Blancas''Octopus Travel QA''Panturismo Marcas Blancas''Parque Tayrona''Representaciones Pasabordo WM''Rokatur Marcas Blancas''RollingTrips''Star World''Swissandina''Takentours''TerraNet Marcas Blancas''Turiscol Ltda.''Aviatur S.A.''Union de Representaciones''Union de Representaciones - Whitemark''Virtuoso''Claro''WeCare''Octopus Travel Ltda.''Aviatur Site''Aviatur S.A.S. - BBVA''Aviatur Welcome Beds'];
  28.         $agencyPromoId 172;
  29.         $validationAgencyFolder false;
  30.         foreach ($agenciesExcluded as $agencyExcluded) {
  31.             if ($agencyExcluded === $agency->getName()) {
  32.                 $agencyPromoId $session->get('agencyId');
  33.                 $validationAgencyFolder true;
  34.             }
  35.         }
  36.         $homePromoList $em->getRepository(HomePromoList::class)->findOneBy([
  37.             'type' => sprintf('__autos%s'$promoType),
  38.             'agency' => $agencyPromoId,
  39.             'online' => true,
  40.         ]);
  41.         if ($homePromoList != null) {
  42.             $homePromoTitle $homePromoList->getTitle();
  43.             $homePromoSubtitle $homePromoList->getSubtitle();
  44.             $homePromos $em->getRepository(HomePromo::class)->findByHomePromoList($homePromoList, ['date' => 'DESC']);
  45.         } else {
  46.             $homePromoTitle null;
  47.             $homePromoSubtitle null;
  48.             $homePromos = [];
  49.         }
  50.         $homePromoListMain $em->getRepository(HomePromoList::class)->findOneBy(["type" => '__autos' $promoTypeMain"agency" => $agencyPromoId"online" => true]);
  51.         if ($homePromoListMain != null) {
  52.             $homePromoMainTitle $homePromoListMain->getTitle();
  53.             $homePromoMainSubtitle $homePromoListMain->getSubtitle();
  54.             $homePromosMain $em->getRepository(HomePromo::class)->findByHomePromoList($homePromoListMain, ['date' => 'DESC']);
  55.         } else {
  56.             $homePromoMainTitle null;
  57.             $homePromoMainSubtitle null;
  58.             $homePromosMain = [];
  59.         }
  60.         $homePromoListRecommendations $em->getRepository(HomePromoList::class)->findOneBy([
  61.             'type' => sprintf('__autos%s'$promoTypeRecommendations),
  62.             'agency' => $agencyPromoId,
  63.             'online' => true,
  64.         ]);
  65.         if ($homePromoListRecommendations != null) {
  66.             $homePromoRecommendationsTitle $homePromoListRecommendations->getTitle();
  67.             $homePromoRecommendationsSubtitle $homePromoListRecommendations->getSubtitle();
  68.             $homePromosRecommendations $em->getRepository(HomePromo::class)->findByHomePromoList($homePromoListRecommendations, ['date' => 'DESC']);
  69.         } else {
  70.             $homePromoRecommendationsTitle null;
  71.             $homePromoRecommendationsSubtitle null;
  72.             $homePromosRecommendations = [];
  73.         }
  74.         $homePromoListFaq $em->getRepository(HomePromoList::class)->findOneBy([
  75.             'type' => '__autos' $promoTypeFaq,
  76.             'agency' => $agencyPromoId,
  77.             'online' => true,
  78.         ]);
  79.         if ($homePromoListFaq != null) {
  80.             $homePromoFaqTitle $homePromoListFaq->getTitle();
  81.             $homePromoFaqSubtitle $homePromoListFaq->getSubtitle();
  82.             $homePromosFaq $em->getRepository(HomePromo::class)->findByHomePromoList($homePromoListFaq, ['date' => 'DESC']);
  83.         } else {
  84.             $homePromoFaqTitle null;
  85.             $homePromoFaqSubtitle null;
  86.             $homePromosFaq = [];
  87.         }
  88.         $agencyFolder $twigFolder->twigFlux();
  89.         return $this->render($twigFolder->twigExists(sprintf('@AviaturTwig/%s/Search/Car/carSearch_index.html.twig'$agencyFolder)), [
  90.             'cookieLastSearch' => $cookieLastSearch,
  91.             'homePromos' => $homePromos,
  92.             'titlePromo' => $homePromoTitle,
  93.             'subtitlePromo' => $homePromoSubtitle,
  94.             'promoType' => '__autos',
  95.             'homePromosMain' => $homePromosMain,
  96.             'titlePromoMain' => $homePromoMainTitle,
  97.             'subtitlePromoMain' => $homePromoMainSubtitle,
  98.             'promoTypeMain' => sprintf('__autos%s'$promoTypeMain),
  99.             'homePromosRecommendations' => $homePromosRecommendations,
  100.             'titlePromoRecommendations' => $homePromoRecommendationsTitle,
  101.             'subtitlePromoRecommendations' => $homePromoRecommendationsSubtitle,
  102.             'promoTypeRecommendations' => sprintf('__autos%s'$promoTypeRecommendations),
  103.             'validationAgencyFolder' => $validationAgencyFolder,
  104.             'homePromosFaq' => $homePromosFaq,
  105.             'titlePromoFaq' => $homePromoFaqTitle,
  106.             'subtitlePromoFaq' => $homePromoFaqSubtitle,
  107.             'promoTypeFaq' => sprintf('__autos%s'$promoTypeFaq),
  108.         ]);
  109.     }
  110. }