Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ruconverter.php
1<?php
2
4
13final class RuConverter extends BaseConverter
14{
16 private const FEDERAL_SUBJECT_ADMIN_LEVEL = 4;
17
19 private const FEDERAL_SUBJECT_MUNICIPAL_DISTRICT_ADMIN_LEVEL = 6;
20
22 private const CITY_FEDERAL_SUBJECT_MUNICIPAL_DISTRICT_ADMIN_LEVEL = 8;
23
29 private const MOSCOW_STATE_RELATION_ID = 102269;
30
36 private const SAINT_PETERSBURG_STATE_RELATION_ID = 337422;
37
43 private const SEVASTOPOL_STATE_RELATION_ID = 1574364;
44
48 protected function getAdminLevel1(): ?array
49 {
50 foreach ($this->addressComponents as $addressComponent)
51 {
52 if ($this->isAdministrativeBoundary($addressComponent)
53 && $addressComponent['admin_level'] === static::FEDERAL_SUBJECT_ADMIN_LEVEL
54 )
55 {
56 return $addressComponent;
57 }
58 }
59
60 return null;
61 }
62
66 protected function getAdminLevel2(): ?array
67 {
68 $municipalDistrictAdminLevel = $this->isCityState()
69 ? static::CITY_FEDERAL_SUBJECT_MUNICIPAL_DISTRICT_ADMIN_LEVEL
70 : static::FEDERAL_SUBJECT_MUNICIPAL_DISTRICT_ADMIN_LEVEL;
71
72 foreach ($this->addressComponents as $addressComponent)
73 {
74 if ($this->isAdministrativeBoundary($addressComponent)
75 && $addressComponent['admin_level'] === $municipalDistrictAdminLevel
76 )
77 {
78 return $addressComponent;
79 }
80 }
81
82 return null;
83 }
84
88 protected function getCityStateRelationIds(): array
89 {
90 return [
91 static::MOSCOW_STATE_RELATION_ID,
92 static::SAINT_PETERSBURG_STATE_RELATION_ID,
93 static::SEVASTOPOL_STATE_RELATION_ID,
94 ];
95 }
96}