src/Controller/Pages/CalendarController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Pages;
  3. use App\Kernel;
  4. use App\Controller\AbstractKasController;
  5. use App\Controller\Database;
  6. use App\Controller\PageInfo;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use App\Controller\Objects\Page;
  12. use Symfony\VarDumper;
  13. class CalendarController extends AbstractKasController
  14. {
  15.     public function __construct(RequestStack $requestStackDatabase $dbPageInfo $pageInfo)
  16.     {
  17.         parent::__construct($requestStack$db$pageInfo);
  18.         $this->request $requestStack->getCurrentRequest();
  19.         $this->model = new CalendarModel($db);
  20.     }
  21.     /**
  22.      * @Route("/kalendar")
  23.      * @return Response
  24.      */
  25.     public function calendar(): Response
  26.     {
  27.         $link $this->request->getRequestUri();
  28.         $page $this->model->getCalendarInfo();
  29.         return $this->render('/pages/calendar.html.twig', [
  30.             'pageinfo' => $this->pageInfo,
  31.             'page' => $page
  32.         ]);
  33.     }
  34.     /**
  35.      * @Route("/kalendar-data")
  36.      * @return JsonResponse
  37.      */
  38.     public function calendarData():JsonResponse
  39.     {
  40.         $object = (int)$this->request->query->get('object');
  41.         $start  $this->request->query->get('start');
  42.         $end    $this->request->query->get('end');
  43.         $events $this->model->getCalendarEvents($object$start$end);
  44.         return new JsonResponse($events);
  45.     }
  46. }
  47. ?>