• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/source/osm/configurer.php
  • Класс: BitrixLocationSourceOsmConfigurer
  • Вызов: Configurer::configure
static function configure(): void
{
	$sourceRepository = new SourceRepository(new OrmConverter());

	$osmSource = $sourceRepository->findByCode(Factory::OSM_SOURCE_CODE);
	if (!$osmSource)
	{
		return;
	}

	$osmConfig = $osmSource->getConfig() ?? new Config();

	$datacenterEndpointsMap = self::getDatacenterEndpointsMap();
	$datacenter = self::getServiceDatacenter();

	$osmConfig->setValue(
		'SERVICE_URL',
		$datacenterEndpointsMap[$datacenter]['SERVICE_URL']
	);

	$mapServiceUrlConfigItem = $osmConfig->getItem('MAP_SERVICE_URL');
	if (!$mapServiceUrlConfigItem)
	{
		$osmConfig->addItem(
			(new ConfigItem('MAP_SERVICE_URL', 'string'))
				->setIsVisible(true)
				->setSort(15)
				->setValue($datacenterEndpointsMap[$datacenter]['MAP_SERVICE_URL'])
		);
	}
	else
	{
		$osmConfig->setValue(
			'MAP_SERVICE_URL',
			$datacenterEndpointsMap[$datacenter]['MAP_SERVICE_URL']
		);
	}

	$sourceRepository->save($osmSource);
}