mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
create event by selecting a calendar range
This commit is contained in:
@@ -22,18 +22,19 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Contains method to get events (Calendar) from remote calendar.
|
||||
*/
|
||||
class RemoteCalendarProxyController
|
||||
{
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private RemoteCalendarConnectorInterface $remoteCalendarConnector;
|
||||
|
||||
private SerializerInterface $serializer;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
public function __construct(PaginatorFactory $paginatorFactory, RemoteCalendarConnectorInterface $remoteCalendarConnector, SerializerInterface $serializer)
|
||||
{
|
||||
$this->paginatorFactory = $paginatorFactory;
|
||||
@@ -51,9 +52,9 @@ class RemoteCalendarProxyController
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
}
|
||||
|
||||
@@ -62,14 +63,15 @@ class RemoteCalendarProxyController
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
}
|
||||
|
||||
$events = $this->remoteCalendarConnector->listEventsForUser($user, $dateFrom, $dateTo);
|
||||
$paginator = $this->paginatorFactory->create(count($events));
|
||||
|
||||
if (count($events) > 0) {
|
||||
$paginator->setItemsPerPage($paginator->getTotalItems());
|
||||
}
|
||||
|
Reference in New Issue
Block a user