mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
38 lines
1.3 KiB
PHP
38 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Chill\CalendarBundle\Controller;
|
|
|
|
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
|
use Chill\MainBundle\Serializer\Model\Collection;
|
|
|
|
class CalendarRangeAPIController extends ApiController
|
|
{
|
|
|
|
/**
|
|
* @Route("/api/1.0/calendar/calendar-range-available.{_format}", name="chill_api_single_calendar_range_available")
|
|
*/
|
|
public function availableRanges(Request $request, string $_format): JsonResponse
|
|
{
|
|
if ($request->query->has('user')) {
|
|
$user = $request->query->get('user');
|
|
}
|
|
|
|
$em = $this->getDoctrine()->getManager();
|
|
|
|
$query = $em->createQuery(
|
|
'SELECT c FROM ChillCalendarBundle:CalendarRange c
|
|
WHERE NOT EXISTS (SELECT cal.id FROM ChillCalendarBundle:Calendar cal WHERE cal.calendarRange = c.id)')
|
|
;
|
|
|
|
$results = $query->getResult();
|
|
|
|
return $this->json(['count' => count($results), 'results' => $results], Response::HTTP_OK, [], [ 'groups' => [ 'read' ]]);
|
|
//TODO use also the paginator, eg return $this->serializeCollection('get', $request, $_format, $paginator, $results);
|
|
}
|
|
|
|
} |