- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/lib/sync/office365/eventmanager.php
- Класс: BitrixCalendarSyncOffice365EventManager
- Вызов: EventManager::prepareSeries
private function prepareSeries($deltaData, SectionConnection $sectionLink): array
{
$result = [];
/** @var EventDto $masterDto */
$masterDto = $deltaData[Helper::EVENT_TYPES['series']];
/** @var EventDto[] $exceptionList */
$exceptionList = $deltaData[Helper::EVENT_TYPES['exception']] ?? [];
$masterEvent = $this->context->getConverter()->convertEvent($masterDto, $sectionLink->getSection());
if (!empty($exceptionList)) {
$exceptionsDates = array_map(function (EventDto $exception) {
return (new MainTypeDateTime(
$exception->start->dateTime,
$this->helper::TIME_FORMAT_LONG,
new DateTimeZone($exception->start->timeZone),
))->format('d.m.Y');
}, $exceptionList
);
$excludeCollection = new CoreEventPropertiesExcludedDatesCollection($exceptionsDates);
$masterEvent->setExcludedDateCollection($excludeCollection);
}
$result[] = [
'type' => 'master',
'id' => $masterDto->id,
'event' => $masterEvent,
'version' => $masterDto->changeKey,
'etag' => $masterDto->etag,
'data' => $this->prepareCustomData($masterDto),
];
foreach ($exceptionList as $exception) {
$event = $this->context->getConverter()->convertEvent($exception, $sectionLink->getSection());
$result[] = [
'type' => 'exception',
'event' => $event,
'id' => $exception->id,
'version' => $exception->changeKey,
'etag' => $exception->etag,
'recurrence' => $exception->seriesMasterId,
'data' => $this->prepareCustomData($exception),
];
}
return $result;
}