• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/managers/dataexchangemanager.php
  • Класс: BitrixCalendarSyncManagersDataExchangeManager
  • Вызов: DataExchangeManager::importAgent
static function importAgent(): string
{
	if (!Loader::includeModule('calendar') || !Loader::includeModule('dav'))
	{
		return "\Bitrix\Calendar\Sync\Managers\DataExchangeManager::importAgent();";
	}

	$connections = self::getConnections();
	/** @var Connection $connection */
	while ($connection = $connections->fetch())
	{
		if ($connection->getOwner() === null)
		{
			self::markDeletedFailedConnection($connection);
			continue;
		}

		try
		{
			/** @var FactoryBase $factory */
			$factory = FactoriesCollection::createByConnection($connection)->fetch();

			if (!$factory)
			{
				continue;
			}

			$exchangeManager = new VendorDataExchangeManager($factory, self::getSyncSectionMap($factory));
			$exchangeManager
				->importSections()
				->importEvents()
				->updateConnection($factory->getConnection())
				->clearCache();
		}
		catch (RemoteAccountException $e)
		{
			self::markDeletedFailedConnection($connection);
		}
		catch (Exception $e)
		{
			$connection->setSyncStatus(Dictionary::SYNC_STATUS['failed']);
		}
	}

	return "\Bitrix\Calendar\Sync\Managers\DataExchangeManager::importAgent();";
}