- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/lib/sync/managers/incomingmanager.php
- Класс: BitrixCalendarSyncManagersIncomingManager
- Вызов: IncomingManager::importSection
private function importSection(
Section $section,
string $vendorId,
string $vendorVersion = null,
bool $isPrimary = false
): SectionConnection
{
$sectionFactory = new SectionConnectionFactory();
$link = $sectionFactory->getSectionConnection([
'filter' => [
'CONNECTION_ID' => $this->connection->getId(),
'VENDOR_SECTION_ID' => $vendorId,
],
'connectionObject' => $this->connection,
]);
if (!$link)
{
$fields = [
'NAME' => $section->getName(),
'ACTIVE' => 'Y',
'DESCRIPTION' => $section->getDescription() ?? '',
'COLOR' => $section->getColor() ?? '',
'CAL_TYPE' => $this->connection->getOwner()
? $this->connection->getOwner()->getType()
: CoreRoleUser::TYPE
,
'OWNER_ID' => $this->connection->getOwner()
? $this->connection->getOwner()->getId()
: null
,
'CREATED_BY' => $this->connection->getOwner()->getId(),
'DATE_CREATE' => new DateTime(),
'TIMESTAMP_X' => new DateTime(),
'EXTERNAL_TYPE' => $this->connection->getVendor()->getCode(),
];
if ($sectionId = CCalendar::SaveSection([
'arFields' => $fields,
'originalFrom' => $this->connection->getVendor()->getCode(),
]))
{
$section = $this->mapperFactory->getSection()->resetCacheById($sectionId)->getById($sectionId);
$protoLink = (new SectionConnection())
->setSection($section)
->setConnection($this->connection)
->setVendorSectionId($vendorId)
->setVersionId($vendorVersion)
->setPrimary($isPrimary)
;
$link = $this->mapperFactory->getSectionConnection()->create($protoLink);
}
else
{
throw new SystemException("Can't create Bitrix Calendar Section", 500, __FILE__, __LINE__ );
}
}
if ($link)
{
$this->subscribeSection($link);
}
return $link;
}