1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sourceselector.php
См. документацию.
1<?php
2
3namespace Bitrix\Location\Source;
4
5use Bitrix\Location\Entity\Source\Factory;
6use Bitrix\Location\Entity\Source\OrmConverter;
7use Bitrix\Location\Infrastructure\SourceCodePicker;
8use Bitrix\Location\Repository\SourceRepository;
9use Bitrix\Location\Source\Google;
10use Bitrix\Location\Source\Osm;
11use Bitrix\Main\Result;
12
14{
16
18 {
19 $this->sourceRepository = $sourceRepository ?: new SourceRepository(new OrmConverter());
20 }
21
22 public function setSource(string $sourceCode, IConfigFactory $configFactory): Result
23 {
24 $result = new Result();
25
26 $source = $this->sourceRepository->findByCode($sourceCode);
27
28 if (!$source)
29 {
30 $source = Factory::makeSource($sourceCode);
31 $source->setName($sourceCode);
32 }
33
34 $source->setConfig(
35 $configFactory->createConfig()
36 );
37
38 $res = $this->sourceRepository->save($source);
39
40 if(!$res->isSuccess())
41 {
42 $result->addErrors($res->getErrors());
43 }
44
45 SourceCodePicker::setSourceCode($sourceCode);
46
47 return $result;
48 }
49
50 public static function setGoogleSource(string $frontendKey, string $backendKey): Result
51 {
52 $sourceSelector = new self();
53 $configFactory = new Google\ConfigFactory($frontendKey, $backendKey);
54 return $sourceSelector->setSource(Factory::GOOGLE_SOURCE_CODE, $configFactory);
55 }
56
57 public static function setOsmSource(string $serviceUrl, string $token): Result
58 {
59 $sourceSelector = new self();
60 $configFactory = new Osm\ConfigFactory($serviceUrl, $token);
61 return $sourceSelector->setSource(Factory::OSM_SOURCE_CODE, $configFactory);
62 }
63}
static setOsmSource(string $serviceUrl, string $token)
Определения sourceselector.php:57
static setGoogleSource(string $frontendKey, string $backendKey)
Определения sourceselector.php:50
setSource(string $sourceCode, IConfigFactory $configFactory)
Определения sourceselector.php:22
__construct(SourceRepository $sourceRepository=null)
Определения sourceselector.php:17
Определения result.php:20
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14