• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/managers/importeventmanager.php
  • Класс: BitrixCalendarSyncManagersImportEventManager
  • Вызов: ImportEventManager::import
public function import(): ImportEventManager
{
	/** @var SyncEntitiesSyncSection $syncSection */
	foreach ($this->syncSectionCollection as $syncSection)
	{
		if (
			$syncSection->getSectionConnection() === null
			|| !$syncSection->getSectionConnection()->isActive()
		)
		{
			continue;
		}

		try
		{
			$result = $this->importManager->getEvents($syncSection);

			if ($result->isSuccess())
			{
				$this->handleCalendarChange(($result->getData()['externalSyncEventMap'])->getCollection());
				$this->externalEventMap->addItems(($result->getData()['externalSyncEventMap'])->getCollection());
				$syncSection
					->getSectionConnection()
					->setLastSyncDate(new CoreBaseDate())
					->setSyncToken($this->importManager->getSyncToken())
					->setPageToken($this->importManager->getPageToken())
					->setLastSyncStatus($this->importManager->getStatus())
					->setVersionId($this->importManager->getEtag())
				;
				$syncSection->setSectionConnection(
					$this->saveSectionConnection($syncSection->getSectionConnection())
				);
			}
		}
		catch (SyncExceptionsNotFoundException $e)
		{
			$syncSection->getSectionConnection()
				->setActive(false)
				->setLastSyncStatus(SyncDictionary::SYNC_STATUS['deleted']);
			$syncSection->setSectionConnection(
				$this->saveSectionConnection($syncSection->getSectionConnection())
			);
		}
		catch (SyncExceptionsAuthException | SyncExceptionsRemoteAccountException $e)
		{
			$syncSection->getSectionConnection()
				->setLastSyncStatus(SyncDictionary::SYNC_STATUS['failed']);
			$syncSection->setSectionConnection(
				$this->saveSectionConnection($syncSection->getSectionConnection())
			);
		}
	}

	return $this;
}