14 private const SERVICE_DATACENTER_RU =
'ru';
15 private const SERVICE_URL_RU =
'https://osm-ru-002.bitrix.info';
16 private const MAP_SERVICE_URL_RU =
'https://osm-ru-001.bitrix.info';
18 private const SERVICE_DATACENTER_DE =
'de';
19 private const SERVICE_URL_DE =
'https://osm-de-002.bitrix.info';
20 private const MAP_SERVICE_URL_DE =
'https://osm-de-001.bitrix.info';
26 $osmSource = $sourceRepository->findByCode(Factory::OSM_SOURCE_CODE);
32 $osmConfig = $osmSource->getConfig() ??
new Config();
34 $datacenterEndpointsMap = self::getDatacenterEndpointsMap();
35 $datacenter = self::getServiceDatacenter();
39 $datacenterEndpointsMap[$datacenter][
'SERVICE_URL']
42 $mapServiceUrlConfigItem = $osmConfig->getItem(
'MAP_SERVICE_URL');
43 if (!$mapServiceUrlConfigItem)
49 ->setValue($datacenterEndpointsMap[$datacenter][
'MAP_SERVICE_URL'])
56 $datacenterEndpointsMap[$datacenter][
'MAP_SERVICE_URL']
60 $sourceRepository->save($osmSource);
66 private static function getServiceDatacenter(): string
71 return self::SERVICE_DATACENTER_RU;
74 if (in_array($region, [
'ru',
'by',
'kz'],
true))
76 return self::SERVICE_DATACENTER_RU;
79 return self::SERVICE_DATACENTER_DE;
85 private static function getDatacenterEndpointsMap(): array
88 self::SERVICE_DATACENTER_RU => [
89 'SERVICE_URL' => self::SERVICE_URL_RU,
90 'MAP_SERVICE_URL' => self::MAP_SERVICE_URL_RU,
92 self::SERVICE_DATACENTER_DE => [
93 'SERVICE_URL' => self::SERVICE_URL_DE,
94 'MAP_SERVICE_URL' => self::MAP_SERVICE_URL_DE,