src/Controller/EventController.php line 696

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Admin\EventAdmin;
  4. use App\Business\BookingOrigin;
  5. use App\Business\EventCategoryProvider;
  6. use App\Entity\Event;
  7. use App\Services\ActionLoggerService;
  8. use App\Services\ContactService;
  9. use App\Services\DashboardService;
  10. use App\Services\Elastic\ElasticNeosService;
  11. use App\Services\EventArticleService;
  12. use App\Services\EventFollowerService;
  13. use App\Services\EventRightAccessService;
  14. use App\Services\EventService;
  15. use App\Services\NewslettersService;
  16. use App\Services\BookingCatalogService;
  17. use App\Services\SplunkService;
  18. use App\Services\UserService;
  19. use App\Services\CustomerOrderService;
  20. use App\Utils\JsonResponseHelper;
  21. use Exception;
  22. use Knp\Snappy\Pdf;
  23. use Symfony\Component\Routing\Annotation\Route;
  24. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  25. use Symfony\Component\HttpFoundation\JsonResponse;
  26. use Symfony\Component\HttpFoundation\RedirectResponse;
  27. use Symfony\Component\HttpFoundation\Request;
  28. use Symfony\Component\HttpFoundation\Response;
  29. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  30. use Symfony\Component\Security\Core\Security as SecurityInterface;
  31. class EventController extends BaseController
  32. {
  33.     /** @var ActionLoggerService $actionLoggerService */
  34.     protected $actionLoggerService;
  35.     /** @var ElasticNeosService $elasticNeosService */
  36.     protected $elasticNeosService;
  37.     /** @var EventService $eventService */
  38.     protected $eventService;
  39.     /** @var ContactService $contactService */
  40.     protected $contactService;
  41.     /** @var EventFollowerService $eventFollowerService */
  42.     protected $eventFollowerService;
  43.     /** @var EventRightAccessService $eventRightAccessService */
  44.     protected $eventRightAccessService;
  45.     /** @var EventUpdatesLinksController $eventUpdatesLinksController */
  46.     protected $eventUpdatesLinksController;
  47.     /** @var UserService $userService */
  48.     protected $userService;
  49.     /** @var DashboardService $dashboardService */
  50.     protected $dashboardService;
  51.     /** @var NewslettersService $newslettersService */
  52.     protected $newslettersService;
  53.     /** @var SplunkService $splunkService */
  54.     private $splunkService;
  55.     /** @var BookingCatalogService $bookingCatalogService */
  56.     private $bookingCatalogService;
  57.     /** @var CustomerOrderService $customerOrderService */
  58.     private $customerOrderService;
  59.     /** @var SecurityInterface $security */
  60.     protected SecurityInterface $security;
  61.     /**
  62.      * EventController constructor.
  63.      *
  64.      * @param EventService $eventService
  65.      * @param ElasticNeosService $elasticNeosService
  66.      * @param ContactService $contactService
  67.      * @param ActionLoggerService $actionLoggerService
  68.      * @param EventRightAccessService $eventRightAccessService
  69.      * @param EventFollowerService $eventFollowerService
  70.      * @param EventUpdatesLinksController $eventUpdatesLinksController
  71.      * @param UserService $userService
  72.      * @param DashboardService $dashboardService
  73.      * @param SplunkService $splunkService
  74.      * @param NewslettersService $newslettersService
  75.      */
  76.     public function __construct(
  77.         EventService $eventService,
  78.         ElasticNeosService $elasticNeosService,
  79.         ContactService $contactService,
  80.         ActionLoggerService $actionLoggerService,
  81.         EventRightAccessService $eventRightAccessService,
  82.         EventFollowerService $eventFollowerService,
  83.         EventUpdatesLinksController $eventUpdatesLinksController,
  84.         UserService $userService,
  85.         DashboardService $dashboardService,
  86.         SplunkService $splunkService,
  87.         NewslettersService $newslettersService,
  88.         BookingCatalogService $bookingCatalogService,
  89.         CustomerOrderService $customerOrderService,
  90.         SecurityInterface $security
  91.     )
  92.     {
  93.         parent::__construct($security);
  94.         $this->eventService $eventService;
  95.         $this->eventRightAccessService $eventRightAccessService;
  96.         $this->elasticNeosService $elasticNeosService;
  97.         $this->contactService $contactService;
  98.         $this->actionLoggerService $actionLoggerService;
  99.         $this->eventFollowerService $eventFollowerService;
  100.         $this->eventUpdatesLinksController $eventUpdatesLinksController;
  101.         $this->userService $userService;
  102.         $this->dashboardService $dashboardService;
  103.         $this->splunkService $splunkService;
  104.         $this->newslettersService $newslettersService;
  105.         $this->bookingCatalogService $bookingCatalogService;
  106.         $this->customerOrderService $customerOrderService;
  107.     }
  108.     /**
  109.      * @Route("/events/all", name="events_all_home", options={"expose" = true }, methods={"GET", "POST"})
  110.      * @Route("/events/all/", name="events_all_home_slash", methods={"GET", "POST"})
  111.      * @Route("/events", name="events_home", methods={"GET", "POST"})
  112.      * @Route("/events/", name="events_home_slash", methods={"GET", "POST"})
  113.      * @Route("/events/all/{category}", name="events_home_with_category", methods={"GET", "POST"})
  114.      * @Route("/events/all/{category}/", name="events_home_with_category_slash", methods={"GET", "POST"})
  115.      * @param Request|null $request
  116.      * @return Response
  117.      */
  118.     public function eventsHomeAction(?Request $request)
  119.     {
  120.         $filter $this->getFilterFromRequest($requesttrue);
  121.         $adminUrl $this->getAdminUrl();
  122.         return $this->render(
  123.             'event/events.html.twig',
  124.             [
  125.                 'location' => 'all',
  126.                 'pageTitle' => 'All Events',
  127.                 'tabTitle' => '',
  128.                 'filter' => $filter,
  129.                 BaseController::PARAM_ADMIN_URL => $adminUrl,
  130.                 'view' => $filter['view']
  131.             ]
  132.         );
  133.     }
  134.     public function getFilterFromRequest(Request $request nullbool $defaultIsYear false)
  135.     {
  136.         $search $request->query->has('search') ? $request->query->get('search') : null;
  137.         $date $request->query->has('date') ? $request->query->get('date') : ($defaultIsYear 'year' 'week');
  138.         $category $request->attributes->has('category') ? $request->get('category') : null;
  139.         $sortedBy $request->query->has('sorted') ? $request->query->get('sorted') : null;
  140.         $view $request->query->has('view') ? $request->query->get('view') : 'xsmall';
  141.         $worldfeed $request->query->has('worldfeed') ? $request->query->get('worldfeed') : false;
  142.         $isRadio $request->query->has('isRadio') ? $request->query->get('isRadio') : false;
  143.         $specials_urls = ["sports""news""culture-and-entertainment"];
  144.         if (in_array($category$specials_urls)) {
  145.             $category null;
  146.         }
  147.         $filter = [
  148.             'search' => $search,
  149.             'date' => $date,
  150.             'category' => $category != "all" $category null,
  151.             'worldfeed' => $worldfeed,
  152.             'isRadio' => $isRadio,
  153.             'sorted' => $sortedBy,
  154.             'view' => $view
  155.         ];
  156.         return $filter;
  157.     }
  158.     /**
  159.      * @return null|string the admin url if the current user can access to it.
  160.      */
  161.     private function getAdminUrl()
  162.     {
  163.         $adminUrl null;
  164.         if ($this->security->isGranted("ROLE_ADMIN_EVENTS_ADMINISTRATOR")) {
  165.             /** @noinspection PhpRouteMissingInspection */
  166.             $adminUrl $this->generateUrl('admin_app_event_list');
  167.         }
  168.         return $adminUrl;
  169.     }
  170.     /**
  171.      * @Route("/events/sports", name="events_sports", options={"expose" = true }, methods={"GET", "POST"})
  172.      * @Route("/events/sports/", name="events_sports_slash", methods={"GET", "POST"})
  173.      * @Route("/events/sports/{category}", name="events_sports_category", methods={"GET", "POST"})
  174.      * @Route("/events/sports/{category}/", name="events_sports_slash_with_category", methods={"GET", "POST"})
  175.      * @param Request|null $request
  176.      * @return Response
  177.      */
  178.     public function eventsSportsAction(Request $request null)
  179.     {
  180.         $filter $this->getFilterFromRequest($requesttrue);
  181.         $adminUrl $this->getAdminUrl();
  182.         return $this->render(
  183.             'event/events.html.twig', [
  184.                 'location' => 'sports',
  185.                 'pageTitle' => EventCategoryProvider::CAT_SPORTS_TITLE,
  186.                 'tabTitle' => EventCategoryProvider::CAT_SPORTS_NAME,
  187.                 'filter' => $filter,
  188.                 BaseController::PARAM_ADMIN_URL => $adminUrl,
  189.                 'view' => $filter['view']
  190.             ]
  191.         );
  192.     }
  193.     /**
  194.      * @Route("/events/culture-and-entertainment", name="events_culture-and-entertainment", options={"expose" = true }, methods={"GET", "POST"})
  195.      * @Route("/events/culture-and-entertainment/", name="events_culture-and-entertainment_slash", methods={"GET", "POST"})
  196.      * @Route("/events/culture-and-entertainment/{category}", name="events_culture-and-entertainment_with_category", methods={"GET", "POST"})
  197.      * @Route("/events/culture-and-entertainment/{category}/", name="events_culture-and-entertainment_slash_with_category", methods={"GET", "POST"})
  198.      * @param Request|null $request
  199.      * @return Response
  200.      */
  201.     public function eventsCultureAndReligionAction(Request $request null)
  202.     {
  203.         $filter $this->getFilterFromRequest($requesttrue);
  204.         $adminUrl $this->getAdminUrl();
  205.         return $this->render(
  206.             'event/events.html.twig', [
  207.                 'location' => 'culture-and-entertainment',
  208.                 'pageTitle' => EventCategoryProvider::CAT_CULTURE_TITLE,
  209.                 'tabTitle' => EventCategoryProvider::CAT_CULTURE_NAME,
  210.                 'filter' => $filter,
  211.                 BaseController::PARAM_ADMIN_URL => $adminUrl,
  212.                 'view' => $filter['view']
  213.             ]
  214.         );
  215.     }
  216.     /**
  217.      * @Route("/intern/events/list", name="events_list", options={"expose" = true }, methods={"GET", "POST"})
  218.      * @param $filter
  219.      * @return Response
  220.      */
  221.     public function eventsListAction(Request $request)
  222.     {
  223.         $eventType $request->query->has('type') ? $request->query->get('type') : 'all';
  224.         $filter $this->getFilterFromRequest($requesttrue);
  225.         $events $this->eventService->getEventsByType($eventType$filternull);
  226.         foreach ($events as $event) {
  227.             $event->currentUserIsFollower $this->getFollowStatus($event->getId());
  228.         }
  229.         return $this->render(
  230.             'event/events_list.html.twig', [
  231.                 'events' => $events,
  232.                 'eventType' => $eventType
  233.             ]
  234.         );
  235.     }
  236.     public function getFollowStatus($eventId)
  237.     {
  238.         $followStatus $this->eventFollowerService->isUserFollowEvent($eventId);
  239.         return $followStatus;
  240.     }
  241.     /**
  242.      * @Route("/events/{eventType}/{category}/{eventNo}/details", name="events_details", options={"expose" = true}, methods={"GET", "POST"})
  243.      * @param SessionInterface $session
  244.      * @param string $category
  245.      * @param string $eventNo
  246.      * @return Response
  247.      * @internal param Event $event
  248.      */
  249.     public function eventsDetailsAction(SessionInterface $sessionstring $categorystring $eventNostring $eventType)
  250.     {
  251.         $event $this->eventService->getEventByNo($eventNo);
  252.         // Get programme and timings list
  253.         if ($event == null) {
  254.             if ($eventType == 'sports') {
  255.                 return $this->redirectToRoute('events_sports');
  256.             } else if ($eventType == 'culture') {
  257.                 return $this->redirectToRoute('events_home');
  258.             } else {
  259.                 return $this->redirectToRoute('events_home');
  260.             }
  261.         }
  262.         if ($event->getStatus() != 'PUBLISHED' && $event->getStatus() != 'PUBLISHED_NO_BOOKINGS') {
  263.             return $this->redirectToRoute('events_home');
  264.         }
  265.         if ($event->isSport()) {
  266.             $redirect $this->redirectToCorrectCategory($eventEventCategoryProvider::CAT_SPORTS$category);
  267.         } else if ($event->isNews()) {
  268.             $redirect $this->redirectToCorrectCategory($eventEventCategoryProvider::CAT_NEWS$category);
  269.         } else {
  270.             $redirect $this->redirectToCorrectCategory($eventEventCategoryProvider::CAT_CULTURE$category);
  271.         }
  272.         if ($redirect != null) {
  273.             return $redirect;
  274.         }
  275.         $bookingUrl $this->generateBookingUrl($event'newbooking-with-input');
  276.         $isRhsBookingAllowed $event->getRhsBookingAllowed();
  277.         $isParticipationAllowed $this->elasticNeosService->hasParticipationsInTheFuture($eventNo);
  278.         $isUnilateralAllowed $this->bookingCatalogService->checkIfEventHasUnilateral($event);
  279.         $rhsActivatedForEvent $this->eventRightAccessService->isRhsEventAccessDefined($event->getId());
  280.         $isWorkspaceBookingAllowed $this->customerOrderService->checkIfEventHasWorkspace($event$rhsActivatedForEvent);
  281.         $adminUrl null;
  282.         if ($this->security->isGranted("ROLE_ADMIN_EVENTS_ADMINISTRATOR")) {
  283.             $adminUrl $this->generateUrl(EventAdmin::PATH_ADMIN_APP_EVENT_EDIT, ['id' => $event->getId()]);
  284.         }
  285.         $userCompanyStatus = (!empty($this->userService->getCurrentUserMainInformation()->memberCompanyStatus)) ? $this->userService->getCurrentUserMainInformation()->memberCompanyStatus null;
  286.         return $this->render(
  287.             'event/events_details.html.twig', [
  288.             'key' => $this->getParameter('google_maps_key'),
  289.             'event' => $event,
  290.             'hasRelatedEvents' => $event->hasRelatedEvents(),
  291.             'hasTransmissions' => $this->elasticNeosService->hasTransmissions($eventNo),
  292.             'isRhsBookingAllowed' => $isRhsBookingAllowed,
  293.             'isParticipationAllowed' => $isParticipationAllowed,
  294.             'isWorkspaceBookingAllowed' => $isWorkspaceBookingAllowed,
  295.             'isUnilateralAllowed' => $isUnilateralAllowed,
  296.             'currentPage' => 1,
  297.             'nbUpdatesPages' => $this->getUser() ? $this->eventUpdatesLinksController->getNbUpdatesPages($this->getUser(), $session$event): null,
  298.             'bookingUrl' => $bookingUrl,
  299.             BaseController::PARAM_ADMIN_URL => $adminUrl,
  300.             'follow' => $this->getFollowStatus($event->getId()),
  301.             'userCompanyStatus' => $userCompanyStatus
  302.         ]);
  303.     }
  304.     /**
  305.      * @param Event $event
  306.      * @param string $initType
  307.      * @param string $iniCategory
  308.      * @return null|RedirectResponse the redirection to the correct type
  309.      */
  310.     private function redirectToCorrectCategory(Event $eventstring $initType nullstring $iniCategory null)
  311.     {
  312.         $mainCat EventCategoryProvider::getMainCategory($event);
  313.         $category $event->getCategoryUrl();
  314.         if ($mainCat != $initType || $iniCategory != $category) {
  315.             $generateEventNoArray self::generateEventNoArray($event);
  316.             $generateEventNoArray['category'] = $category;
  317.             if ($mainCat == EventCategoryProvider::CAT_NEWS) {
  318.                 $generateEventNoArray['eventType'] = 'news';
  319.             }
  320.             if ($mainCat == EventCategoryProvider::CAT_CULTURE) {
  321.                 $generateEventNoArray['eventType'] = 'culture-and-entertainment';
  322.             } else {
  323.                 $generateEventNoArray['eventType'] = 'sports';
  324.             }
  325.             return $this->redirectToRoute('events_details',
  326.                 $generateEventNoArray);
  327.         }
  328.         return null;
  329.     }
  330.     /**
  331.      * @param Event $event
  332.      * @return array
  333.      */
  334.     private static function generateEventNoArray(Event $event): array
  335.     {
  336.         return [Event::PROP_EVENT_NO => $event->getEventNo()];
  337.     }
  338.     private function generateBookingUrl(Event $eventstring $route): ?string
  339.     {
  340.         if (!$event->isBookable()) {
  341.             return null;
  342.         }
  343.         if (empty($route)) {
  344.             $route 'newbooking-with-input';
  345.         }
  346.         return $this->generateUrl($route,
  347.             ['type' => strtolower(BookingOrigin::TYPE_EVENT), 'code' => $event->getEventNo()]);
  348.     }
  349.     /**
  350.      * @Route("/events/{eventType}/{category}/{eventNo}/worldfeed/{transmissionNo}", name="events_details_worldfeed", methods={"GET", "POST"})
  351.      * @param Request $request
  352.      * @param string $eventType
  353.      * @param string $category
  354.      * @param string $eventNo
  355.      * @param string $transmissionNo
  356.      * @return Response
  357.      */
  358.     public function eventsDetailsWorldfeedAction(Request $requeststring $eventTypestring $categorystring $eventNostring $transmissionNo)
  359.     {
  360.         // Add worldfeed details log for the splunk dashboard
  361.         $worldFeed $this->eventService->getWorldfeedByNo($transmissionNo);
  362.         $this->dashboardService->addCustomLog($worldFeed'GET_WORLDFEED_DETAILS'$this->generateUrl('events_details_worldfeed', ['eventType' => $eventType'category' => $category'eventNo' => $eventNo'transmissionNo' => $transmissionNo]));
  363.         return $this->renderWorldFeed($eventNo$transmissionNo$request);
  364.     }
  365.     /**
  366.      * @param string $eventNo
  367.      * @param string $transmissionNo
  368.      * @param bool $directAccessTechnicalDetails
  369.      * @param Request $request
  370.      * @return Response
  371.      */
  372.     public function renderWorldFeed(string $eventNostring $transmissionNoRequest $request): Response
  373.     {
  374.         $worldFeed $this->eventService->getWorldfeedByNo($transmissionNo);
  375.         $event $this->eventService->getEventByNo($eventNo);
  376.         if (empty($worldFeed) || empty($event)) {
  377.             return $this->redirectToRoute('events_all_home');
  378.         }
  379.         $adminUrl null;
  380.         if ($this->security->isGranted("ROLE_ADMIN_EVENTS_ADMINISTRATOR")) {
  381.             $adminUrl $this->generateUrl(EventAdmin::PATH_ADMIN_APP_EVENT_EDIT, ['id' => $event->getId()]);
  382.         }
  383.         $synopsis $this->dashboardService->getSynopsisTextDetails($transmissionNo"f049c00d5f8368fad9a7b8b2a55ee6efabd87399");
  384.         return $this->render(
  385.             'event/events_worldfeed_details.html.twig', [
  386.             'event' => $event,
  387.             'user' => $this->getUser(),
  388.             'worldfeed' => $worldFeed,
  389.             'synopsis' => $synopsis,
  390.             'city' => $this->eventService->getLocationCityCountry($worldFeed),
  391.             'source' => $this->eventService->getSourceName($worldFeed),
  392.             'directAccessTechnicalDetails' => $request->get('directAccessTechnicalDetails'),
  393.             BaseController::PARAM_ADMIN_URL => $adminUrl,
  394.             'follow' => $this->getFollowStatus($event->getId())
  395.         ]);
  396.     }
  397.     /**
  398.      * warning: the route name is used in EventAdmin in a constant.
  399.      * @Route("/events/from-id/{id}", name="events_from_id_details", options={"expose" = true }, methods={"GET", "POST"})
  400.      * @Security("is_granted('ROLE_USER')")
  401.      * @param string $id
  402.      * @return Response* @internal param Event $event
  403.      */
  404.     public function eventsFromIdDetailsAction(
  405.         string $id
  406.     )
  407.     {
  408.         $event $this->eventService->getEventById($id);
  409.         if ($event != null) {
  410.             $redirect $this->redirectToCorrectCategory($eventnullnull);
  411.             if ($redirect != null) {
  412.                 return $redirect;
  413.             }
  414.         }
  415.         return $this->redirectToRoute('events_home');
  416.     }
  417.     /**
  418.      * warning: the route name is used in EventAdmin in a constant.
  419.      * @Route("/events/from-no/{eventNo}", name="events_from_no_details", options={"expose" = true }, methods={"GET", "POST"})
  420.      * @Security("is_granted('ROLE_USER')")
  421.      * @param string $eventNo
  422.      * @return Response* @internal param Event $event
  423.      */
  424.     public
  425.     function eventsFromNoDetailsAction(
  426.         string $eventNo
  427.     )
  428.     {
  429.         $event $this->eventService->getEventByNo($eventNo);
  430.         if ($event != null) {
  431.             $redirect $this->redirectToCorrectCategory($eventnullnull);
  432.             if ($redirect != null) {
  433.                 return $redirect;
  434.             }
  435.         }
  436.         return $this->redirectToRoute('events_home');
  437.     }
  438.     /**
  439.      * @Route("/intern/events/follow/{eventId}", name="event_follow", options={"expose" = true }, methods={"GET", "POST"})
  440.      * @Security("is_granted('ROLE_USER')")
  441.      * @param $eventId
  442.      * @return Response
  443.      */
  444.     public function eventFollowAction(string $eventId)
  445.     {
  446.         $event $this->eventService->getEventById($eventId);
  447.         if ($event == null) {
  448.             $event $this->eventService->getEventByNo($eventId);
  449.             if ($event == null) {
  450.                 return JsonResponseHelper::buildErrorJson("Error to unfollow unknown event");
  451.             }
  452.         }
  453.         if ($this->getFollowStatus($event->getId())) {
  454.             try {
  455.                 $this->eventFollowerService->unFollowEventForCurrentUser($event->getId());
  456.                 $this->actionLoggerService->getLogger()
  457.                     ->info("user unfollow event " $event->getEventNo() . " with success");
  458.                 return JsonResponseHelper::buildSuccessJson("Unfollow Event with success"'text''UNFOLLOW');
  459.             } catch (Exception $e) {
  460.                 return JsonResponseHelper::buildErrorJson("Error to unfollow event : " $e->getMessage());
  461.             }
  462.         } else {
  463.             try {
  464.                 $this->eventFollowerService->followEventForCurrentUser($event);
  465.                 $this->actionLoggerService->getLogger()
  466.                     ->info("user follow event " $event->getEventNo() . " with success");
  467.                 return JsonResponseHelper::buildSuccessJson("Follow Event with success"'text''FOLLOW');
  468.             } catch (Exception $e) {
  469.                 return JsonResponseHelper::buildErrorJson("Error to follow event : " $e->getMessage());
  470.             }
  471.         }
  472.     }
  473.     /**
  474.      * @Route("/events/follow/{eventId}/by-email", name="event_follow_by_email", options={"expose" = true }, methods={"GET", "POST"})
  475.      * @Security("is_granted('ROLE_USER')")
  476.      * @param Request $request
  477.      * @param $eventId
  478.      * @return Response
  479.      */
  480.     public function eventFollowByEmailAction(Request $requeststring $eventId)
  481.     {
  482.         $event $this->eventService->getEventById($eventId);
  483.         if ($event == null) {
  484.             $event $this->eventService->getEventByNo($eventId);
  485.         }
  486.         if (!empty($event) && !$this->getFollowStatus($event->getId())) {
  487.             $this->eventFollowerService->followEventForCurrentUser($event);
  488.             $this->actionLoggerService->getLogger()
  489.                 ->info("user follow event " $event->getEventNo() . " with success");
  490.         }
  491.         return $this->redirectToRoute('my_events', ['byEmail' => true]);
  492.     }
  493.     /**
  494.      * @Route("/intern/events/is-follower/{eventId}", name="is_event_follower", options={"expose" = true }, methods={"GET", "POST"})
  495.      * @Security("is_granted('ROLE_USER')")
  496.      * @param $eventId
  497.      * @return Response
  498.      */
  499.     public function isEventFollowerAction(string $eventId)
  500.     {
  501.         $event $this->eventService->getEventById($eventId);
  502.         if ($event == null) {
  503.             $event $this->eventService->getEventByNo($eventId);
  504.             if ($event == null) {
  505.                 return JsonResponseHelper::buildErrorJson("Error to unfollow unknown event");
  506.             }
  507.         }
  508.         if ($this->getFollowStatus($event->getId())) {
  509.             return $this->json(["isFollower" => true]);
  510.         } else {
  511.             return $this->json(["isFollower" => false]);
  512.         }
  513.     }
  514.     /**
  515.      * @Route("/intern/events/is-similar-event-subscriber/{eventId}", name="is_similar_event_subscriber", options={"expose" = true }, methods={"GET", "POST"})
  516.      * @Security("is_granted('ROLE_USER')")
  517.      * @param $eventId
  518.      * @return Response
  519.      */
  520.     public function isSimilarEventSubscriberAction(string $eventId)
  521.     {
  522.         $event $this->eventService->getEventById($eventId);
  523.         if ($event == null) {
  524.             $event $this->eventService->getEventByNo($eventId);
  525.             if ($event == null) {
  526.                 return JsonResponseHelper::buildErrorJson("Error to unfollow unknown event");
  527.             }
  528.         }
  529.         $sonataClassificationService $this->newslettersService->getSonataClassificationService();
  530.         $context $sonataClassificationService->getContext($event->getContextId());
  531.         //we retrieve the real category of the event to add the group of interests:
  532.         if ($context != null) {
  533.             $eventRealCategory $sonataClassificationService->getCategory($context$event->getContextMainCategoryId(), $event->getContextCategoryId());
  534.             $isAlreadyRegisteredSimilarEvent $this->newslettersService->isUserRegisteredInCategory($this->getUser()->getUid(), $eventRealCategoryfalse);
  535.             $newsletterGroupId $newsletterGroupId $this->newslettersService->getInterestGroupInterestId($eventRealCategoryfalse);
  536.             if ($isAlreadyRegisteredSimilarEvent) {
  537.                 return $this->json(["isSubscriber" => true"newsletterGroupId" => $newsletterGroupId]);
  538.             } else {
  539.                 return $this->json(["isSubscriber" => false"newsletterGroupId" => $newsletterGroupId]);
  540.             }
  541.         }
  542.         return $this->json(["isSubscriber" => true"newsletterGroupId" => ""]);
  543.     }
  544.     /**
  545.      * @Route("/intern/events/unfollow/all", name="event_unfollow_all", options={"expose" = true }, methods={"GET", "POST"})
  546.      * @Security("is_granted('ROLE_USER')")
  547.      * @return Response
  548.      */
  549.     public function unfollowAllEvents()
  550.     {
  551.         try {
  552.             $this->eventFollowerService->unfollowAllEventsForCurrentUser();
  553.             $this->actionLoggerService->getLogger()->info("User unfollow all events with success");
  554.             return JsonResponseHelper::buildSuccessJson('You unfollow all events');
  555.         } catch (Exception $e) {
  556.             return JsonResponseHelper::buildErrorJson("Error to unfollow all events : " $e->getMessage());
  557.         }
  558.     }
  559.     /**
  560.      * @Route("/intern/event/participations/{eventNo}", name="event_transmissions_participations", options={"expose" = true }, methods={"GET", "POST"})
  561.      * @param Request $request
  562.      * @param string $eventNo
  563.      * @return Response
  564.      */
  565.     public function getTransmissionParticipations(Request $requeststring $eventNo)
  566.     {
  567.         $includePastTransmission = (!empty($request->get('includePastTransmission')) && $request->get('includePastTransmission') == 'true') ? true false;
  568.         $transmissions = [];
  569.         $atLeastOneGroup false;
  570.         $atLeastOneMdsChannel false;
  571.         try {
  572.             $event $this->eventService->getEventByNo($eventNo);
  573.             $transmissions $this->elasticNeosService->getTransmissionByEventNo($eventNo$event->getShowUnisInTransmissions(), $includePastTransmission'asc');
  574.             if (!empty($transmissions)) {
  575.                 foreach ($transmissions as $transmission) {
  576.                     if (!empty($transmission['transmissionGroup'])) {
  577.                         $atLeastOneGroup true;
  578.                     }
  579.                     if (!empty($transmission['mdsChannel'])) {
  580.                         $atLeastOneMdsChannel true;
  581.                     }
  582.                 }
  583.             }
  584.         } catch (Exception $ex) {
  585.             $this->actionLoggerService->getLogger()->error("cant get transmission", ["exception" => $ex]);
  586.         }
  587.         return $this->render(
  588.             'event/event_programme_list_table.html.twig', [
  589.             'transmissions' => $transmissions,
  590.             'atLeastOneGroup' => $atLeastOneGroup,
  591.             'atLeastOneMdsChannel' => $atLeastOneMdsChannel,
  592.             'event' => $this->eventService->getEventByNo($eventNo)
  593.         ]);
  594.     }
  595.     /**
  596.      * @Route("/intern/events/{eventNo}/timeline", name="event_timeline", options={"expose" = true })
  597.      * @param $eventNo
  598.      * @return Response
  599.      */
  600.     public function getEventTimelineAction(string $eventNo)
  601.     {
  602.         $event $this->eventService->getEventByNo($eventNo);
  603.         $transmissions $this->elasticNeosService->getTransmissionByEventNo($eventNo$event->getShowUnisInTransmissions(), true'asc');
  604.         // Group transmissions by mdsChannel / path
  605.         $groups = [];
  606.         $groupType 'channel';
  607.         foreach ($transmissions as $transmission) {
  608.             if (!empty($transmission['mdsChannel']) && !in_array($transmission['mdsChannel'], $groups)) {
  609.                 array_push($groups$transmission['mdsChannel']);
  610.             } else {
  611.                 if (empty($transmission['mdsChannel']) && !in_array("No Channel"$groups)) {
  612.                     array_push($groups"No Channel");
  613.                 }
  614.             }
  615.         }
  616.         sort($groups);
  617.         if (count($groups ?? []) === || count($groups ?? []) === 1) {
  618.             $groups = [];
  619.             $groupType 'path';
  620.             foreach ($transmissions as $transmission) {
  621.                 if (!empty($transmission['path']) && !in_array($transmission['path'], $groups)) {
  622.                     array_push($groups$transmission['path']);
  623.                 } else {
  624.                     if (empty($transmission['path']) && !in_array("No Channel"$groups)) {
  625.                         array_push($groups"No Channel");
  626.                     }
  627.                 }
  628.             }
  629.             usort($groups, function ($a$b) {
  630.                 if ($a == "No Channel" || $b == "No Channel") {
  631.                     return 1;
  632.                 }
  633.                 return strcmp($a$b);
  634.             });
  635.         }
  636.         return $this->render(
  637.             'event/event_timeline.html.twig', [
  638.                 'transmissions' => $transmissions,
  639.                 'groups' => $groups,
  640.                 'groupType' => $groupType,
  641.                 'organizationCode' => $this->userService->getCurrentUserCodeOps()
  642.             ]
  643.         );
  644.     }
  645.     /**
  646.      * @Route("/intern/events/getupcoming", name="event_upcoming", options={"expose" = true }, methods={"GET", "POST"})
  647.      * @return Response
  648.      */
  649.     public function getUpcomingEventsAction()
  650.     {
  651.         $events $this->eventService->getUpcomingEvents(4null);
  652.         return $this->render(
  653.             'dashboard/upcoming_events.html.twig', [
  654.             'events' => $events
  655.         ]);
  656.     }
  657.     /**
  658.      * @Route("/intern/event/details/pdf/{eventNo}", name="event_details_get_pdf", options={"expose" = true})
  659.      * @Security("is_granted('ROLE_USER')")
  660.      * @param string $eventNo
  661.      * @return Response
  662.      */
  663.     public function getEventDetailsPDF(
  664.         string $eventNo,
  665.         Request $request,
  666.         EventAccessController $accessController,
  667.         SessionInterface $session,
  668.         EventArticleService $eventArticleService,
  669.         Pdf $pdf
  670.     )
  671.     {
  672.         $event $this->eventService->getEventByNo($eventNo);
  673.         $transmissions = [];
  674.         try {
  675.             $transmissions $this->elasticNeosService->getTransmissionByEventNo($eventNo$event->getShowUnisInTransmissions(), true'asc');
  676.         } catch (Exception $ex) {
  677.             $this->actionLoggerService->getLogger()->error("cant get transmission", ["exception" => $ex]);
  678.         }
  679.         $includeInactive $this->includeInactive($session);
  680.         $result $eventArticleService->getUpdates($accessController->getCurrentUserUid(), $event1100$includeInactive);
  681.         $neosDocuments $this->eventService->getEventAttachments($eventNo);
  682.         $eventMainCategory $event->getContextMainCategoryId();
  683.         $eventCategory $event->getCategoryUrl();
  684.         $html $this->renderView('event/event_details_pdf.html.twig', [
  685.             'event' => $event,
  686.             'transmissions' => $transmissions,
  687.             'eventArticles' => $result['collection'],
  688.             'neosDocuments' => $neosDocuments,
  689.             'eventMainCategory' => $eventMainCategory,
  690.             'eventCategory' => $eventCategory
  691.         ]);
  692.         $header $this->renderView('event/event_details_pdf_header.html.twig');
  693.         $footer $this->renderView('event/event_details_pdf_footer.html.twig');
  694.         $filename 'event_' $eventNo '_details';
  695.         return new Response(
  696.             $pdf->getOutputFromHtml($html, [
  697.                 'header-html' => $header,
  698.                 'footer-html' => $footer,
  699.             ]), 200, [
  700.                 'Content-Type' => 'application/pdf',
  701.                 'Content-Disposition' => 'attachment; filename="' $filename '.pdf"'
  702.             ]
  703.         );
  704.     }
  705.     /**
  706.      * @Route("/intern/event/worldfeed/stats/{transmissionNo}", name="event_worldfeed_stats", options={"expose" = true})
  707.      * @Security("is_granted('ROLE_USER')")
  708.      * @param string $transmissionNo
  709.      * @return Response
  710.      */
  711.     public function getWorldfeedStatsLocal(string $transmissionNoRequest $request)
  712.     {
  713.         $response $this->eventService->searchSpecificStatsWorldFeedInLocalDb($transmissionNo$this->getUser()->getEmail());
  714.         return $this->json("Email sent!");
  715.     }
  716.     /**
  717.      * @param $event
  718.      * @return string
  719.      */
  720.     private function generateRhsBookingUrl(Event $event null): ?string
  721.     {
  722.         if ($event != null && $this->getUser() != null) {
  723.             return $this->generateUrl('rhs_myorders'self::generateEventNoArray($event));
  724.         }
  725.         return null;
  726.     }
  727.     /**
  728.      * @Route("/intern/events/banner/view/list-event/{eventNo}", name="list_banner_event", options={"expose" = true })
  729.      * @param string $eventNo
  730.      * @return mixed
  731.      */
  732.     public function getEventBannersVisibleAndNotReadAction(string $eventNo)
  733.     {
  734.         $uid null;
  735.         if ($this->getUser() != null) {
  736.             $uid $this->getUser()->getUid();
  737.         }
  738.         $event $this->eventService->getEventByNo($eventNo);
  739.         $filteredAlerts $this->eventService->getVisibleAndNotReadEventBanners($event->getId(), $event->getCategoryCode(), $uid);
  740.         if ($filteredAlerts == null) {
  741.             $filteredAlerts = [];
  742.         }
  743.         return $this->render(
  744.             'block/alert.html.twig',
  745.             [
  746.                 'alerts' => $filteredAlerts,
  747.                 'isEvent' => true
  748.             ]
  749.         );
  750.     }
  751.     /**
  752.      * @Route("/intern/events/banner/view/save/{idBanner}", name="banner_view_save", options={"expose" = true }, methods={"GET"})
  753.      * @param string|null $idBanner
  754.      * @return JsonResponse
  755.      */
  756.     public function saveBannerView(string $idBanner null): JsonResponse
  757.     {
  758.         if ($this->getUser() == null || $idBanner === null) {
  759.             return JsonResponseHelper::buildErrorJson("Not saved as user is not logged in");
  760.         }
  761.         try {
  762.             $this->eventService->setBannerReadByCurrentUser($this->getUser()->getUid(), $idBanner);
  763.             return JsonResponseHelper::buildSuccessJson("Banner view saved");
  764.         } catch (Exception $e) {
  765.             return JsonResponseHelper::buildErrorJson("Error to save banner view : " $e->getMessage());
  766.         }
  767.     }
  768.     /**
  769.      * @Route("/intern/events/default-image-info/{eventNo}", name="events_default_image", options={"expose" = true})
  770.      * @Security("is_granted('ROLE_USER')")
  771.      * @param string $eventNo
  772.      * @return Response
  773.      */
  774.     public function getEventDefaultImageAction(string $eventNo)
  775.     {
  776.         $event $this->eventService->getEventByNo($eventNo);
  777.         return $this->render(
  778.             'event/event_default_image.html.twig',
  779.             [
  780.                 'event' => $event
  781.             ]
  782.         );
  783.     }
  784. }