mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
send first calendar on ms graph
This commit is contained in:
@@ -11,8 +11,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
@@ -29,13 +33,16 @@ class RemoteEventConverter
|
||||
|
||||
private DateTimeZone $defaultDateTimeZone;
|
||||
|
||||
private PersonRenderInterface $personRender;
|
||||
|
||||
private DateTimeZone $remoteDateTimeZone;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
public function __construct(PersonRenderInterface $personRender, TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->personRender = $personRender;
|
||||
$this->defaultDateTimeZone = (new DateTimeImmutable())->getTimezone();
|
||||
$this->remoteDateTimeZone = self::getRemoteTimeZone();
|
||||
}
|
||||
@@ -71,6 +78,42 @@ class RemoteEventConverter
|
||||
];
|
||||
}
|
||||
|
||||
public function calendarToEvent(Calendar $calendar): array
|
||||
{
|
||||
return [
|
||||
'subject' => '[Chill] ' .
|
||||
implode(
|
||||
', ',
|
||||
$calendar->getPersons()->map(function (Person $p) {
|
||||
return $this->personRender->renderString($p, []);
|
||||
})->toArray()
|
||||
),
|
||||
'start' => [
|
||||
'dateTime' => $calendar->getStartDate()->setTimezone($this->remoteDateTimeZone)
|
||||
->format(self::REMOTE_DATE_FORMAT),
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
'end' => [
|
||||
'dateTime' => $calendar->getEndDate()->setTimezone($this->remoteDateTimeZone)
|
||||
->format(self::REMOTE_DATE_FORMAT),
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
'allowNewTimeProposals' => false,
|
||||
'attendees' => $calendar->getInvites()->map(
|
||||
static function (Invite $i) {
|
||||
return [
|
||||
'emailAddress' => [
|
||||
'address' => $i->getUser()->getEmail(),
|
||||
'name' => $i->getUser()->getLabel(),
|
||||
],
|
||||
'type' => 'Required',
|
||||
];
|
||||
}
|
||||
)->toArray(),
|
||||
'transactionId' => 'calendar_' . $calendar->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
public function convertAvailabilityToRemoteEvent(array $event): RemoteEvent
|
||||
{
|
||||
$startDate =
|
||||
|
Reference in New Issue
Block a user