src/Controller/FacilityController.php line 20

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Elements.at New Media Solutions GmbH
  4.  *
  5.  */
  6. namespace App\Controller;
  7. use App\Service\FacilityService;
  8. use Pimcore\Model\DataObject\TicketMachine;
  9. use Pimcore\Model\Exception\NotFoundException;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. class FacilityController extends AbstractController
  15. {
  16.     public function overviewAction(Request $requestFacilityService $service): Response
  17.     {
  18.         $tabs $service->getResortTabs($this->document->getEditable('resorts'));
  19.         $returnArray = [
  20.             'tabs' => $tabs,
  21.             'facilitiesCount' => $service->getFacilitiesCount(),
  22.         ];
  23.         if ($request->get('ajax')) {
  24.             $template $this->renderTemplate('facility/partials/facility-tabbing-ajax-result.html.twig'$returnArray);
  25.             return $this->json(['success' => true'html' => $template->getContent()]);
  26.         }
  27.         return $this->render('facility/overview.html.twig'$returnArray);
  28.     }
  29.     public function openingHoursAction(Request $request): Response
  30.     {
  31.         $pois = [];
  32.         $poiListing = new TicketMachine\Listing();
  33.         $poiListing->addConditionParam('coordinates__longitude IS NOT NULL AND coordinates__latitude IS NOT NULL');
  34.         foreach ($poiListing as $poi) {
  35.             $pois[] = [
  36.                 'id' => $poi->getId(),
  37.                 'lng' => $poi->getCoordinates()->getLongitude(),
  38.                 'lat' => $poi->getCoordinates()->getLatitude(),
  39.                 'poiStyle' => 'main',
  40.                 'detailInfoBoxUrl' => $this->generateUrl('google_map_hotspot_modal', [ 'id' => $poi->getId() ]),
  41.             ];
  42.         }
  43.         return $this->render('facility/opening-hours.html.twig', [ 'pois' => $pois ]);
  44.     }
  45.     public function mapAction(Request $request): Response
  46.     {
  47.         return $this->render('facility/map.html.twig');
  48.     }
  49.     /**
  50.      * @param Request $request
  51.      *
  52.      * @return Response
  53.      *
  54.      * @Route("/{_locale}/google-map-hotspot-modal?id={id}", name="google_map_hotspot_modal")
  55.      */
  56.     public function googleMapHotspotModal(Request $request): Response
  57.     {
  58.         $poi TicketMachine::getById($request->get('id'));
  59.         if (!$poi instanceof TicketMachine || !$poi->isPublished()) {
  60.             throw new NotFoundException();
  61.         }
  62.         $template $this->renderTemplate('includes/overlays/google-map-hotspot-modal.html.twig', [ 'poi' => $poi ]);
  63.         return new JsonResponse([ 'success' => true'html' => $template->getContent() ]);
  64.     }
  65. }