src/Controller/Legacy/VistaManzanilloController.php line 113
<?phpnamespace App\Controller\Legacy;use App\Models\AdminModuleType;use App\Models\AdminSection;use App\Models\AdminSubSection;use App\Models\ContentType;use App\Repository\BannerRepository;use App\Repository\ContentRepository;use App\Repository\GalleryRepository;use App\Repository\ModuleRepository;use App\Repository\PromotionRepository;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\JsonResponse;use Symfony\Component\HttpFoundation\Request;class VistaManzanilloController extends AbstractController{private AdminSection $section = AdminSection::VistaManzanillo;private BannerRepository $bannerRepository;private ContentRepository $contentRepository;private GalleryRepository $galleryRepository;private ModuleRepository $moduleRepository;private PromotionRepository $promotionRepository;public function __construct(BannerRepository $bannerRepository,ContentRepository $contentRepository,GalleryRepository $galleryRepository,ModuleRepository $moduleRepository,PromotionRepository $promotionRepository){$this->bannerRepository = $bannerRepository;$this->contentRepository = $contentRepository;$this->galleryRepository = $galleryRepository;$this->moduleRepository = $moduleRepository;$this->promotionRepository = $promotionRepository;}public function indexAction(){$subSection = AdminSubSection::Hotel;$parametros = array('banners' => $this->bannerRepository->findPublic($this->section, $subSection),'galeriaMomentos' => $this->contentRepository->findPublic($this->section, AdminSubSection::MagicMoments, ContentType::HotelSection),'texto' => $this->contentRepository->findPublic($this->section, $subSection, ContentType::HotelText),'video' => $this->contentRepository->findPublic($this->section, AdminSubSection::Video, ContentType::HotelSection),);return $this->render('VistaManzanillo/index.html.twig', $parametros);}public function instalacionesAction(){$subSection = AdminSubSection::Facilities;$parametros = array('banners' => $this->bannerRepository->findPublic($this->section, $subSection),'texto' => $this->contentRepository->findPublic($this->section, $subSection, ContentType::HotelText),'modulos' => $this->moduleRepository->findPublic($this->section, AdminModuleType::Facilities),'video' => $this->contentRepository->findPublic($this->section, AdminSubSection::Video, ContentType::HotelSection),);return $this->render('VistaManzanillo/instalaciones.html.twig', $parametros);}public function hospedajeAction(){$subSection = AdminSubSection::Lodging;$texto = $this->contentRepository->findPublic($this->section, $subSection, ContentType::HotelText);$listasDeAmenidades = $this->createListOfAmenities($texto->getContent()['amenities'] ?? []);$parametros = array('banners' => $this->bannerRepository->findPublic($this->section, $subSection),'texto' => $texto,'listasDeAmenidades' => $listasDeAmenidades,'modulos' => $this->moduleRepository->findPublic($this->section, AdminModuleType::Lodging),'video' => $this->contentRepository->findPublic($this->section, AdminSubSection::Video, ContentType::HotelSection),);return $this->render('VistaManzanillo/hospedaje.html.twig', $parametros);}public function restaurantesAction(){$subSection = AdminSubSection::Restaurants;$parametros = array('banners' => $this->bannerRepository->findPublic($this->section, $subSection),'texto' => $this->contentRepository->findPublic($this->section, $subSection, ContentType::HotelText),'modulos' => $this->moduleRepository->findPublic($this->section, AdminModuleType::Restaurants),'video' => $this->contentRepository->findPublic($this->section, AdminSubSection::Video, ContentType::HotelSection),);return $this->render('VistaManzanillo/restaurantes.html.twig', $parametros);}public function timeAction(){date_default_timezone_set('America/Cancun');$tiempo = array('horas' => date('H'),'minutos' => date('i'),'segundos' => date('s'),);return new JsonResponse($tiempo);}public function entretenimientoAction(){$subSection = AdminSubSection::Entertainment;$parametros = array('banners' => $this->bannerRepository->findPublic($this->section, $subSection),'texto' => $this->contentRepository->findPublic($this->section, $subSection, ContentType::HotelText),'modulos' => $this->moduleRepository->findPublic($this->section, AdminModuleType::Activities),'show' => $this->contentRepository->findPublic($this->section, AdminSubSection::Shows, ContentType::HotelSection),'video' => $this->contentRepository->findPublic($this->section, AdminSubSection::Video, ContentType::HotelSection),);return $this->render("VistaManzanillo/entretenimiento.html.twig", $parametros);}public function galeriaAction(){$subSection = AdminSubSection::Galleries;$parametros = array('galerias' => $this->galleryRepository->findPublic($this->section),'texto' => $this->contentRepository->findPublic($this->section, $subSection, ContentType::HotelText),'video' => $this->contentRepository->findPublic($this->section, AdminSubSection::Video, ContentType::HotelSection),);return $this->render("VistaManzanillo/galeria.html.twig", $parametros);}public function getRenderGaleriaAction(Request $request){$id = $request->get('id');$galeria = $this->galleryRepository->findOneBy(['id' => $id, 'isVisible' => true]);if ($galeria == null) {$galeria = $this->galleryRepository->findOneBy(['isVisible' => true, 'section' => $this->section]);}$parametros = array('galeria' => $galeria);return $this->render('templates/_galeria.html.twig', $parametros);}function detallesPromocionAction($id, $seccion){$promocionActual = $this->promotionRepository->findOneBy(['id' => $id ?? 0, 'isVisible' => true]);$promociones = $this->promotionRepository->findPublic($this->section);$parametros = array('promocionActual' => $promocionActual,'promociones' => $promociones);return $this->render('VistaManzanillo/promocion.html.twig', $parametros);}private function createListOfAmenities($amenidades){if ($amenidades == null) {return null;}$listas = array();$indiceDeLista = 0;$numeroDeListas = 3;foreach ($amenidades as $amenidad) {$listas[$indiceDeLista][] = $amenidad;$indiceDeLista++;if ($indiceDeLista >= $numeroDeListas)$indiceDeLista = 0;}return $listas;}}