1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
baseconverter.php
См. документацию.
1<?php
2
3namespace Bitrix\Location\Source\Google\Converters;
4
5use Bitrix\Location\Entity\Address;
6use Bitrix\Location\Entity\Address\FieldType;
7use Bitrix\Location\Entity\Format\TemplateType;
8use Bitrix\Location\Entity\Location;
9use Bitrix\Location\Service\FormatService;
10use Bitrix\Location\Entity\Address\Converter\StringConverter;
11
16abstract class BaseConverter
17{
18 protected $languageId = '';
19
23 public function __construct(string $languageId)
24 {
25 $this->languageId = $languageId;
26 }
27
32 abstract public function convert(array $data);
33
34 public function isPostCode(array $types)
35 {
36 return in_array('postal_code', $types);
37 }
38
44 public function convertTypes(array $types, string $typesClass): int
45 {
46 $result = $typesClass::UNKNOWN;
47
48 foreach($types as $type)
49 {
51
52 if(!$typesClass::isValueExist($result))
53 {
54 $result = $typesClass::UNKNOWN;
55 continue;
56 }
57
58 if($result !== $typesClass::UNKNOWN)
59 {
60 break;
61 }
62 }
63
64 return $result;
65 }
66
67 protected function createAddress(array $addressComponents): Address
68 {
69 $address = new Address($this->languageId);
70
71 foreach ($addressComponents as $item)
72 {
73 if ($type = $this->convertTypes($item['types'], FieldType::class))
74 {
75 $address->setFieldValue((int)$type, (string)$item['long_name']);
76 }
77 }
78
79 $format = FormatService::getInstance()->findDefault($this->languageId);
80
81 $addressLine1 = StringConverter::convertToStringTemplate(
82 $address,
83 $format->getTemplate(TemplateType::ADDRESS_LINE_1),
84 StringConverter::STRATEGY_TYPE_TEMPLATE,
85 StringConverter::CONTENT_TYPE_TEXT
86 );
87
88 if($addressLine1)
89 {
90 $address->setFieldValue(FieldType::ADDRESS_LINE_1, $addressLine1);
91 }
92
93 return $address;
94 }
95}
$type
Определения options.php:106
createAddress(array $addressComponents)
Определения baseconverter.php:67
convertTypes(array $types, string $typesClass)
Определения baseconverter.php:44
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14