1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
location.php
См. документацию.
1<?php
2
3namespace Bitrix\Location\Controller;
4
5use Bitrix\Location\Entity\Location\Parents;
6use Bitrix\Location\Infrastructure\Service\ErrorService;
7use Bitrix\Location\Repository\FormatRepository;
8use Bitrix\Location\Service;
9use Bitrix\Location\Entity;
10use Bitrix\Main\Engine\Response\AjaxJson;
11use Bitrix\Location\Entity\Location\Converter\ArrayConverter;
12use Bitrix\Main\Engine\Controller;
13use Bitrix\Main\Result;
14
20class Location extends Controller
21{
22 protected function getDefaultPreFilters()
23 {
24 return [];
25 }
26
32 public function findByIdAction(int $locationId, string $languageId)
33 {
34 $result = null;
35 $location = Service\LocationService::getInstance()->findById($locationId, $languageId);
36
37 if ($location)
38 {
39 $result = $location->toArray();
40 }
41 elseif ($location === false)
42 {
43 if (ErrorService::getInstance()->hasErrors())
44 {
45 $result = AjaxJson::createError(
46 ErrorService::getInstance()->getErrors()
47 );
48 }
49 }
50
51 return $result;
52 }
53
62
68 {
69 $result = new Parents();
70
71 $entity = Entity\Location::fromArray($location);
72
73 if ($entity)
74 {
75 $parents = $entity->getParents();
76
77 if ($parents)
78 {
79 $result = ArrayConverter::convertParentsToArray($parents);
80 }
81 else if($parents === false)
82 {
83 if (ErrorService::getInstance()->hasErrors())
84 {
85 $result = AjaxJson::createError(
86 ErrorService::getInstance()->getErrors()
87 );
88 }
89 }
90 }
91
92 return $result;
93 }
94
99 public function findByExternalIdAction(string $externalId, string $sourceCode, string $languageId)
100 {
101 $result = null;
102 $location = Service\LocationService::getInstance()->findByExternalId($externalId, $sourceCode, $languageId);
103
104 /* Temporary. To decrease the usage of the Google API */
105 if ($location && $location->getId() > 0)
106 {
107 $externalLocation = Service\LocationService::getInstance()->findByExternalId(
108 $externalId,
109 $sourceCode,
110 $languageId,
112 );
113
114 if ($externalLocation)
115 {
116 $location->setAddress($externalLocation->getAddress());
117 }
118 }
119
120 if ($location)
121 {
122 $result = ArrayConverter::convertToArray($location);
123 }
124 else
125 {
126 if (ErrorService::getInstance()->hasErrors())
127 {
128 $result = AjaxJson::createError(
129 ErrorService::getInstance()->getErrors()
130 );
131 }
132 }
133
134 return $result;
135 }
136
137 public function findByCoordsAction(float $lat, float $lng, int $zoom, string $languageId)
138 {
139 $result = null;
140
141 $location = Service\LocationService::getInstance()->findByCoords($lat, $lng, $zoom, $languageId);
142
143 if ($location)
144 {
145 $result = ArrayConverter::convertToArray($location);
146 }
147 else
148 {
149 if (ErrorService::getInstance()->hasErrors())
150 {
151 $result = AjaxJson::createError(
152 ErrorService::getInstance()->getErrors()
153 );
154 }
155 }
156
157 return $result;
158 }
159
160 public static function saveAction(array $location): array
161 {
162 $entity = Entity\Location::fromArray($location);
163 $result = $entity->save();
164
165 return [
166 'isSuccess' => $result->isSuccess(),
167 'errors' => $result->getErrorMessages(),
168 'location' => ArrayConverter::convertToArray($entity),
169 ];
170 }
171
173 {
175 Entity\Location::fromArray($location)
176 );
177 }
178}
static getInstance()
Определения baseservice.php:21
findByIdAction(int $locationId, string $languageId)
Определения location.php:32
findByExternalIdAction(string $externalId, string $sourceCode, string $languageId)
Определения location.php:99
findParentsAction(array $location)
Определения location.php:67
autocompleteAction(array $params)
Определения location.php:58
deleteAction(array $location)
Определения location.php:172
findByCoordsAction(float $lat, float $lng, int $zoom, string $languageId)
Определения location.php:137
static saveAction(array $location)
Определения location.php:160
</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
$entity
const LOCATION_SEARCH_SCOPE_EXTERNAL
Определения include.php:5
Определения ufield.php:9
getErrors()
Определения errorableimplementation.php:34
hasErrors()
Определения errorableimplementation.php:17
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$location
Определения options.php:2729