- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/lib/sync/office365/sectionmanager.php
- Класс: Bitrix\Calendar\Sync\Office365\SectionManager
- Вызов: SectionManager::create
public function create(Section $section, SectionContext $context): Result
{
$result = new Result();
$dto = new SectionDto([
'name' => $this->getSectionName($section),
'color' => ColorConverter::toOffice($section->getColor()),
]);
$sectionDto = $this->context->getVendorSyncService()->createSection($dto);
if (!empty($sectionDto->id) && !empty($sectionDto->changeKey))
{
$sectionConnection = (new SectionConnection())
->setSection($section)
->setConnection($this->connection)
->setVendorSectionId($sectionDto->id)
->setVersionId($sectionDto->changeKey)
->setLastSyncStatus(Sync\Dictionary::SYNC_STATUS['success'])
->setOwner($section->getOwner())
->setActive(true)
;
$syncSection = (new SyncSection())
->setSection($section)
->setSectionConnection($sectionConnection)
->setVendorName($section->getExternalType())
->setAction(Sync\Dictionary::SYNC_STATUS['success'])
;
$result->setData([
$sectionDto->id => $syncSection,
'id' => $sectionDto->id,
'version' => $sectionDto->changeKey,
'syncSection' => $syncSection,
]);
}
else
{
$result->addError(new Error('Error of create section into Office365'));
}
return $result;
}