src/Controller/Shop/Json/EventJsonController.php line 23

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Elements.at New Media Solutions GmbH
  4.  *
  5.  */
  6. namespace App\Controller\Shop\Json;
  7. use App\Controller\AbstractController;
  8. use App\Model\Shop\Event\EventProduct;
  9. use App\Model\Type\TenantType;
  10. use App\Service\Shop\JsonDataService;
  11. use Carbon\Carbon;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Contracts\Translation\TranslatorInterface;
  16. /**
  17.  * @Route("/{_locale}/shop/event")
  18.  */
  19. class EventJsonController extends AbstractController
  20. {
  21.     /**
  22.      * @Route("/calendar-dates", name="json_event_calendar_dates", methods={"GET"})
  23.      */
  24.     public function calendarDatesJson(Request $requestJsonDataService $jsonDataService): Response
  25.     {
  26.         return $this->json($jsonDataService->getCalendarDates($request));
  27.     }
  28.     /**
  29.      * @Route("/b2b-calendar-dates", name="json_b2b_event_calendar_dates", methods={"GET"})
  30.      */
  31.     public function b2bCalendarDatesJson(Request $requestJsonDataService $jsonDataService): Response
  32.     {
  33.         $this->setEnvironmentTenant(TenantType::B2B);
  34.         return $this->json($jsonDataService->getCalendarDates($request));
  35.     }
  36.     /**
  37.      * @Route("/list-dates", name="json_event_list_dates", methods={"GET"})
  38.      */
  39.     public function listDatesJson(Request $requestJsonDataService $jsonDataService): Response
  40.     {
  41.         return $this->json($jsonDataService->getListDatesJson(intval($request->get('activityId'))));
  42.     }
  43.     /**
  44.      * @Route("/b2b-list-dates", name="json_b2b_event_list_dates", methods={"GET"})
  45.      */
  46.     public function b2bListDatesJson(Request $requestJsonDataService $jsonDataService): Response
  47.     {
  48.         $this->setEnvironmentTenant(TenantType::B2B);
  49.         return $this->json($jsonDataService->getListDatesJson(intval($request->get('activityId'))));
  50.     }
  51.     /**
  52.      * @Route("/time-list-dates", name="json_event_time_list_dates", methods={"GET"})
  53.      */
  54.     public function timeListDatesJson(Request $requestJsonDataService $jsonDataService): Response
  55.     {
  56.         return $this->json($jsonDataService->getTimeListDatesJson(intval($request->get('activityId')), $request->get('selectedDateEnd')));
  57.     }
  58.     /**
  59.      * @Route("/b2b-time-list-dates", name="json_b2b_event_time_list_dates", methods={"GET"})
  60.      */
  61.     public function b2bTimeListDatesJson(Request $requestJsonDataService $jsonDataService): Response
  62.     {
  63.         $this->setEnvironmentTenant(TenantType::B2B);
  64.         return $this->json($jsonDataService->getTimeListDatesJson(intval($request->get('activityId')), $request->get('selectedDateEnd')));
  65.     }
  66.     /**
  67.      * @Route("/base_price", name="json_event_base_price", methods={"GET"})
  68.      */
  69.     public function basePriceJson(Request $requestTranslatorInterface $trans): Response
  70.     {
  71.         $json = [];
  72.         if ($product EventProduct::getById(intval($request->get('activityId')))) {
  73.             $selectedDate null;
  74.             if ($date $request->get('selectedDate')) {
  75.                 $selectedDate Carbon::createFromDate($date);
  76.             }
  77.             $priceInfo $product->getOSPriceInfo(1null$selectedDate);
  78.             /** @phpstan-ignore-next-line */
  79.             $price $priceInfo $priceInfo->getOriginalPriceInfo()->getBaseAmount() : 0;
  80.             $json = [
  81.                 'success' => true,
  82.                 'id' => (string)$request->get('activityId'),
  83.                 'basePriceInfo' => [
  84.                     'label' => $trans->trans('shop.configuration.adult-price'),
  85.                     'price' => $price,
  86.                 ],
  87.             ];
  88.         }
  89.         return $this->json($json);
  90.     }
  91. }