wip: synchro of calendar range

This commit is contained in:
2022-05-11 12:17:29 +02:00
parent ba8a2327be
commit e895da31d7
17 changed files with 492 additions and 4 deletions

View File

@@ -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 =