<?php
namespace App\Controller\Pages;
use App\Kernel;
use App\Controller\AbstractKasController;
use App\Controller\Database;
use App\Controller\PageInfo;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use App\Controller\Objects\Page;
use Symfony\VarDumper;
class CalendarController extends AbstractKasController
{
public function __construct(RequestStack $requestStack, Database $db, PageInfo $pageInfo)
{
parent::__construct($requestStack, $db, $pageInfo);
$this->request = $requestStack->getCurrentRequest();
$this->model = new CalendarModel($db);
}
/**
* @Route("/kalendar")
* @return Response
*/
public function calendar(): Response
{
$link = $this->request->getRequestUri();
$page = $this->model->getCalendarInfo();
return $this->render('/pages/calendar.html.twig', [
'pageinfo' => $this->pageInfo,
'page' => $page
]);
}
/**
* @Route("/kalendar-data")
* @return JsonResponse
*/
public function calendarData():JsonResponse
{
$object = (int)$this->request->query->get('object');
$start = $this->request->query->get('start');
$end = $this->request->query->get('end');
$events = $this->model->getCalendarEvents($object, $start, $end);
return new JsonResponse($events);
}
}
?>