src/Controller/Legacy/VistaManzanilloController.php line 113

  1. <?php
  2. namespace App\Controller\Legacy;
  3. use App\Models\AdminModuleType;
  4. use App\Models\AdminSection;
  5. use App\Models\AdminSubSection;
  6. use App\Models\ContentType;
  7. use App\Repository\BannerRepository;
  8. use App\Repository\ContentRepository;
  9. use App\Repository\GalleryRepository;
  10. use App\Repository\ModuleRepository;
  11. use App\Repository\PromotionRepository;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\HttpFoundation\JsonResponse;
  14. use Symfony\Component\HttpFoundation\Request;
  15. class VistaManzanilloController extends AbstractController
  16. {
  17.     private AdminSection $section AdminSection::VistaManzanillo;
  18.     private BannerRepository $bannerRepository;
  19.     private ContentRepository $contentRepository;
  20.     private GalleryRepository $galleryRepository;
  21.     private ModuleRepository $moduleRepository;
  22.     private PromotionRepository $promotionRepository;
  23.     public function __construct(
  24.         BannerRepository    $bannerRepository,
  25.         ContentRepository   $contentRepository,
  26.         GalleryRepository   $galleryRepository,
  27.         ModuleRepository    $moduleRepository,
  28.         PromotionRepository $promotionRepository
  29.     )
  30.     {
  31.         $this->bannerRepository $bannerRepository;
  32.         $this->contentRepository $contentRepository;
  33.         $this->galleryRepository $galleryRepository;
  34.         $this->moduleRepository $moduleRepository;
  35.         $this->promotionRepository $promotionRepository;
  36.     }
  37.     public function indexAction()
  38.     {
  39.         $subSection AdminSubSection::Hotel;
  40.         $parametros = array(
  41.             'banners' => $this->bannerRepository->findPublic($this->section$subSection),
  42.             'galeriaMomentos' => $this->contentRepository->findPublic($this->sectionAdminSubSection::MagicMomentsContentType::HotelSection),
  43.             'texto' => $this->contentRepository->findPublic($this->section$subSectionContentType::HotelText),
  44.             'video' => $this->contentRepository->findPublic($this->sectionAdminSubSection::VideoContentType::HotelSection),
  45.         );
  46.         return $this->render('VistaManzanillo/index.html.twig'$parametros);
  47.     }
  48.     public function instalacionesAction()
  49.     {
  50.         $subSection AdminSubSection::Facilities;
  51.         $parametros = array(
  52.             'banners' => $this->bannerRepository->findPublic($this->section$subSection),
  53.             'texto' => $this->contentRepository->findPublic($this->section$subSectionContentType::HotelText),
  54.             'modulos' => $this->moduleRepository->findPublic($this->sectionAdminModuleType::Facilities),
  55.             'video' => $this->contentRepository->findPublic($this->sectionAdminSubSection::VideoContentType::HotelSection),
  56.         );
  57.         return $this->render('VistaManzanillo/instalaciones.html.twig'$parametros);
  58.     }
  59.     public function hospedajeAction()
  60.     {
  61.         $subSection AdminSubSection::Lodging;
  62.         $texto $this->contentRepository->findPublic($this->section$subSectionContentType::HotelText);
  63.         $listasDeAmenidades $this->createListOfAmenities($texto->getContent()['amenities'] ?? []);
  64.         $parametros = array(
  65.             'banners' => $this->bannerRepository->findPublic($this->section$subSection),
  66.             'texto' => $texto,
  67.             'listasDeAmenidades' => $listasDeAmenidades,
  68.             'modulos' => $this->moduleRepository->findPublic($this->sectionAdminModuleType::Lodging),
  69.             'video' => $this->contentRepository->findPublic($this->sectionAdminSubSection::VideoContentType::HotelSection),
  70.         );
  71.         return $this->render('VistaManzanillo/hospedaje.html.twig'$parametros);
  72.     }
  73.     public function restaurantesAction()
  74.     {
  75.         $subSection AdminSubSection::Restaurants;
  76.         $parametros = array(
  77.             'banners' => $this->bannerRepository->findPublic($this->section$subSection),
  78.             'texto' => $this->contentRepository->findPublic($this->section$subSectionContentType::HotelText),
  79.             'modulos' => $this->moduleRepository->findPublic($this->sectionAdminModuleType::Restaurants),
  80.             'video' => $this->contentRepository->findPublic($this->sectionAdminSubSection::VideoContentType::HotelSection),
  81.         );
  82.         return $this->render('VistaManzanillo/restaurantes.html.twig'$parametros);
  83.     }
  84.     public function timeAction()
  85.     {
  86.         date_default_timezone_set('America/Cancun');
  87.         $tiempo = array(
  88.             'horas' => date('H'),
  89.             'minutos' => date('i'),
  90.             'segundos' => date('s'),
  91.         );
  92.         return new JsonResponse($tiempo);
  93.     }
  94.     public function entretenimientoAction()
  95.     {
  96.         $subSection AdminSubSection::Entertainment;
  97.         $parametros = array(
  98.             'banners' => $this->bannerRepository->findPublic($this->section$subSection),
  99.             'texto' => $this->contentRepository->findPublic($this->section$subSectionContentType::HotelText),
  100.             'modulos' => $this->moduleRepository->findPublic($this->sectionAdminModuleType::Activities),
  101.             'show' => $this->contentRepository->findPublic($this->sectionAdminSubSection::ShowsContentType::HotelSection),
  102.             'video' => $this->contentRepository->findPublic($this->sectionAdminSubSection::VideoContentType::HotelSection),
  103.         );
  104.         return $this->render("VistaManzanillo/entretenimiento.html.twig"$parametros);
  105.     }
  106.     public function galeriaAction()
  107.     {
  108.         $subSection AdminSubSection::Galleries;
  109.         $parametros = array(
  110.             'galerias' => $this->galleryRepository->findPublic($this->section),
  111.             'texto' => $this->contentRepository->findPublic($this->section$subSectionContentType::HotelText),
  112.             'video' => $this->contentRepository->findPublic($this->sectionAdminSubSection::VideoContentType::HotelSection),
  113.         );
  114.         return $this->render("VistaManzanillo/galeria.html.twig"$parametros);
  115.     }
  116.     public function getRenderGaleriaAction(Request $request)
  117.     {
  118.         $id $request->get('id');
  119.         $galeria $this->galleryRepository->findOneBy(['id' => $id'isVisible' => true]);
  120.         if ($galeria == null) {
  121.             $galeria $this->galleryRepository->findOneBy(['isVisible' => true'section' => $this->section]);
  122.         }
  123.         $parametros = array(
  124.             'galeria' => $galeria
  125.         );
  126.          
  127.         return $this->render('templates/_galeria.html.twig'$parametros);
  128.     }
  129.     function detallesPromocionAction($id$seccion)
  130.     {
  131.         $promocionActual $this->promotionRepository->findOneBy(['id' => $id ?? 0'isVisible' => true]);
  132.         $promociones $this->promotionRepository->findPublic($this->section);
  133.         $parametros = array(
  134.             'promocionActual' => $promocionActual,
  135.             'promociones' => $promociones
  136.         );
  137.          
  138.         return $this->render('VistaManzanillo/promocion.html.twig'$parametros);
  139.     }
  140.     private function createListOfAmenities($amenidades)
  141.     {
  142.         if ($amenidades == null) {
  143.             return null;
  144.         }
  145.         $listas = array();
  146.         $indiceDeLista 0;
  147.         $numeroDeListas 3;
  148.         foreach ($amenidades as $amenidad) {
  149.             $listas[$indiceDeLista][] = $amenidad;
  150.             $indiceDeLista++;
  151.             if ($indiceDeLista >= $numeroDeListas)
  152.                 $indiceDeLista 0;
  153.         }
  154.         return $listas;
  155.     }
  156. }