• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/google/builders/buildersyncsectionfromexternaldata.php
  • Класс: BitrixCalendarSyncGoogleBuildersBuilderSyncSectionFromExternalData
  • Вызов: BuilderSyncSectionFromExternalData::build
public function build()
{
	if ($this->connection->getOwner() === null)
	{
		throw new CoreBaseBaseException('The connection must have an owner');
	}

	$section = (new Section())
		->setName($this->item['summary'])
		->setColor($this->item['backgroundColor'])
		->setOwner($this->connection->getOwner())
		->setCreator($this->connection->getOwner())
		->setExternalType(GoogleDictionary::ACCESS_ROLE_TO_EXTERNAL_TYPE[$this->item['accessRole']])
		->setType(CoreEventToolsDictionary::EVENT_TYPE[CoreRoleUser::TYPE])
		->setIsActive(true)
		->setDescription($this->item['description'] ?? null)
	;

	$sectionConnection = (new SectionConnection())
		->setVendorSectionId($this->item['id'])
		->setActive(true)
		->setLastSyncDate(null)
		->setPrimary($this->item['primary'] ?? false)
		->setSection($section)
		->setOwner($this->connection->getOwner())
		->setLastSyncStatus(Dictionary::SYNC_STATUS['success'])
		->setConnection($this->connection)
		->setVersionId($this->item['etag'])
	;

	$syncSection = (new SyncSection())
		->setSection($section)
		->setSectionConnection($sectionConnection)
		->setVendorName(Factory::SERVICE_NAME)
	;

	if (!empty($this->item['deleted']))
	{
		$syncSection->setAction(Dictionary::SYNC_SECTION_ACTION['delete']);
	}
	else
	{
		$syncSection->setAction(Dictionary::SYNC_SECTION_ACTION['success']);
	}

	return $syncSection;
}