mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
wip: synchro of calendar range
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
@@ -22,6 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
*/
|
||||
class RemoteEventConverter
|
||||
{
|
||||
public const REMOTE_DATETIMEZONE_FORMAT = 'Y-m-d\\TH:i:s.u?P';
|
||||
|
||||
private const REMOTE_DATE_FORMAT = 'Y-m-d\TH:i:s.u0';
|
||||
|
||||
private DateTimeZone $defaultDateTimeZone;
|
||||
@@ -37,6 +40,37 @@ class RemoteEventConverter
|
||||
$this->remoteDateTimeZone = self::getRemoteTimeZone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a CalendarRange into a representation suitable for storing into MSGraph.
|
||||
*
|
||||
* @return array an array representation for event in MS Graph
|
||||
*/
|
||||
public function calendarRangeToEvent(CalendarRange $calendarRange): array
|
||||
{
|
||||
return [
|
||||
'subject' => $this->translator->trans('remote_calendar.calendar_range_title'),
|
||||
'start' => [
|
||||
'dateTime' => $calendarRange->getStartDate()->setTimezone($this->remoteDateTimeZone)
|
||||
->format(self::REMOTE_DATE_FORMAT),
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
'end' => [
|
||||
'dateTime' => $calendarRange->getEndDate()->setTimezone($this->remoteDateTimeZone)
|
||||
->format(self::REMOTE_DATE_FORMAT),
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
'attendees' => [
|
||||
[
|
||||
'emailAddress' => [
|
||||
'address' => $calendarRange->getUser()->getEmailCanonical(),
|
||||
'name' => $calendarRange->getUser()->getLabel(),
|
||||
],
|
||||
],
|
||||
],
|
||||
'isReminderOn' => false,
|
||||
];
|
||||
}
|
||||
|
||||
public function convertAvailabilityToRemoteEvent(array $event): RemoteEvent
|
||||
{
|
||||
$startDate =
|
||||
|
Reference in New Issue
Block a user