• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/factories/factoriescollection.php
  • Класс: BitrixCalendarSyncFactoriesFactoriesCollection
  • Вызов: FactoriesCollection::createByUserId
static function createByUserId(int $userId, array $availableService = []): FactoriesCollection
{
	$collection = [];
	if (!Loader::includeModule('dav'))
	{
		return new self($collection);
	}

	if (!$availableService)
	{
		$availableService = [
			SyncGoogleFactory::SERVICE_NAME,
			SyncIcloudFactory::SERVICE_NAME,
			SyncOffice365Factory::SERVICE_NAME,
		];
	}

	$sectionConnection = DavConnectionTable::query()
		->setSelect(['*'])
		->where('ENTITY_ID', $userId)
		->where('ENTITY_TYPE', 'user')
		->where('IS_DELETED', 'N')
		->whereIn('ACCOUNT_TYPE', $availableService)
		->exec()
	;
	$context = new Context([]);

	while ($connectionDM = $sectionConnection->fetchObject())
	{
		$connection = (new SyncBuildersBuilderConnectionFromDM($connectionDM))->build();

		$collection[] = FactoryBuilder::create(
			$connection->getVendor()->getCode(),
			$connection,
			$context
		);
	}

	return new self($collection);
}