src/Controller/EventController.php line 107

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\{RequestResponse};
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Utils\Ticketing;
  7. use App\Utils\Functions;
  8. class EventController extends AbstractController
  9. {
  10.     private $ticketing;
  11.     private $functions;
  12.     public function __construct(Ticketing $ticketingFunctions $functions)
  13.     {
  14.         $this->ticketing $ticketing;
  15.         $this->functions $functions;
  16.     }
  17.     /**
  18.      * @Route("/events", name="events")
  19.      */
  20.     public function events(Request $request): Response
  21.     {
  22.         $session $request->getSession();
  23.         if($request->get("ref")){
  24.             $session->set('ref'$request->get("ref"));
  25.         }
  26.         
  27.         $events $this->ticketing->curl("events?orderBy=eventDate&order=ASC""normal", array(), "GET");
  28.         
  29.         if(!$events || $events["code"]!="200"){
  30.             $this->addFlash(
  31.                 'notice',
  32.                 'No se han encontrado eventos!'
  33.             );
  34.             return $this->redirectToRoute('home');
  35.         }
  36.         return $this->render('events/events.html.twig', [
  37.             "events" => $events["events"],
  38.         ]);
  39.     }
  40.     /**
  41.      * @Route("/event-tickets", name="event-tickets")
  42.      */
  43.     public function eventTickets(Request $request): Response
  44.     {
  45.         $session $request->getSession();
  46.         $filters=array_filter($request->query->all());
  47.         if($request->get("ref")){
  48.             $session->set('ref'$request->get("ref"));
  49.         }
  50.         if(!$request->get("event")){
  51.             $this->addFlash(
  52.                 'notice',
  53.                 'No se puede acceder al evento'
  54.             );
  55.             return $this->redirectToRoute('home');
  56.         }
  57.         $eventId=$request->get("event");
  58.         $event $this->ticketing->curl("events/".$eventId"normal", array(), "GET");
  59.         if(!$event || $event["code"]!="200" || !$event["enabled"]){
  60.             $this->addFlash(
  61.                 'notice',
  62.                 'No se puede acceder al evento'
  63.             );
  64.             return $this->redirectToRoute('home');
  65.         }
  66.         if($request->get("format")){
  67.             $format=$request->get("format");
  68.         }else{
  69.             $format=1;
  70.         };
  71.         if(!$request->get("order") || $request->get("order")==1){
  72.             if(!$request->get("format") || $request->get("format")=="1"){
  73.                 $limit=4;
  74.             }
  75.             else{
  76.                 $limit=100;
  77.             }
  78.         }
  79.         else{
  80.             $limit=100;
  81.         }
  82.         $configs=array("limit" => $limit"small" => 1"group" => 1"type" => 2);
  83.         
  84.         foreach($configs as $key => $config){
  85.             $request->request->set($key$config);
  86.             $filters[$key]=$config;
  87.         }
  88.         return $this->render('events/event-tickets.html.twig', [
  89.             'filters' => $filters,
  90.             'format' => $format,
  91.             'event' => $event
  92.         ]);
  93.     }
  94. }