1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
location.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Location\Controller;
4
5
use Bitrix\Location\Entity\Location\Parents;
6
use Bitrix\Location\Infrastructure\Service\ErrorService;
7
use Bitrix\Location\Repository\FormatRepository;
8
use Bitrix\Location\Service;
9
use Bitrix\Location\Entity;
10
use Bitrix\Main\Engine\Response\AjaxJson;
11
use Bitrix\Location\Entity\Location\Converter\ArrayConverter;
12
use Bitrix\Main\Engine\Controller;
13
use Bitrix\Main\Result;
14
20
class
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
58
public
function
autocompleteAction
(
array
$params
)
59
{
60
return
Service\LocationService::getInstance
()->autocomplete(
$params
,
LOCATION_SEARCH_SCOPE_EXTERNAL
);
61
}
62
67
public
function
findParentsAction
(
array
$location
)
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,
111
LOCATION_SEARCH_SCOPE_EXTERNAL
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
172
public
function
deleteAction
(
array
$location
):
Result
173
{
174
return
Service\LocationService::getInstance
()->delete(
175
Entity
\Location::fromArray(
$location
)
176
);
177
}
178
}
Bitrix\Location\Common\BaseService\getInstance
static getInstance()
Определения
baseservice.php:21
Bitrix\Location\Controller\Location\getDefaultPreFilters
getDefaultPreFilters()
Определения
location.php:22
Bitrix\Location\Controller\Location\findByIdAction
findByIdAction(int $locationId, string $languageId)
Определения
location.php:32
Bitrix\Location\Controller\Location\findByExternalIdAction
findByExternalIdAction(string $externalId, string $sourceCode, string $languageId)
Определения
location.php:99
Bitrix\Location\Controller\Location\findParentsAction
findParentsAction(array $location)
Определения
location.php:67
Bitrix\Location\Controller\Location\autocompleteAction
autocompleteAction(array $params)
Определения
location.php:58
Bitrix\Location\Controller\Location\deleteAction
deleteAction(array $location)
Определения
location.php:172
Bitrix\Location\Controller\Location\findByCoordsAction
findByCoordsAction(float $lat, float $lng, int $zoom, string $languageId)
Определения
location.php:137
Bitrix\Location\Controller\Location\saveAction
static saveAction(array $location)
Определения
location.php:160
Bitrix\Location\Entity\Location\Parents
Определения
parents.php:13
Bitrix\Main\ORM\Data\Result
Определения
result.php:16
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
LOCATION_SEARCH_SCOPE_EXTERNAL
const LOCATION_SEARCH_SCOPE_EXTERNAL
Определения
include.php:5
Bitrix\Location\Entity\Location
Определения
collection.php:3
Bitrix\Main\Controller
Определения
agreement.php:2
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main\getErrors
getErrors()
Определения
errorableimplementation.php:34
Bitrix\Main\hasErrors
hasErrors()
Определения
errorableimplementation.php:17
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$location
$location
Определения
options.php:2729
bitrix
modules
location
lib
controller
location.php
Создано системой
1.14.0