Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
address.php
1
<?php
2
3
namespace
Bitrix\Location\Controller
;
4
5
use
Bitrix\Location\Entity\Address\Converter\ArrayConverter
;
6
use
Bitrix\Location\Infrastructure\Service\ErrorService
;
7
use
Bitrix\Location\Service
;
8
use
Bitrix\Main\Engine\ActionFilter\Cors
;
9
15
class
Address
extends
\Bitrix\Main\Engine\Controller
16
{
17
protected
function
init
()
18
{
19
parent::init();
20
ErrorService::getInstance()->setThrowExceptionOnError(
true
);
21
}
22
23
protected
function
getDefaultPreFilters
()
24
{
25
return
[];
26
}
27
35
public
function
findById
(
int
$addressId): array
36
{
37
$result =
null
;
38
39
if
($address = Service\
AddressService::getInstance
()->
findById
($addressId))
40
{
41
$result = ArrayConverter::convertToArray($address);
42
}
43
44
return
$result;
45
}
46
51
protected
function
createArrayFromAddressCollection
(array $collection): array
52
{
53
$result = [];
54
55
foreach
($collection as $address)
56
{
57
$result[] = ArrayConverter::convertToArray($address);
58
}
59
60
return
$result;
61
}
62
67
public
static
function
saveAction
(array $address): array
68
{
69
$entity = ArrayConverter::convertFromArray($address);
70
$result = $entity->save();
71
72
return
[
73
'isSuccess'
=> $result->isSuccess(),
74
'errors'
=> $result->getErrorMessages(),
75
'address'
=> ArrayConverter::convertToArray($entity)
76
];
77
}
78
84
public
function
deleteAction
(
int
$addressId): \
Bitrix
\Main\ORM\Data\
DeleteResult
85
{
86
return
Service\AddressService::getInstance()->delete($addressId);
87
}
88
}
Bitrix\Location\Common\BaseService\getInstance
static getInstance()
Definition
baseservice.php:22
Bitrix\Location\Controller\Address
Definition
address.php:16
Bitrix\Location\Controller\Address\getDefaultPreFilters
getDefaultPreFilters()
Definition
address.php:23
Bitrix\Location\Controller\Address\init
init()
Definition
address.php:17
Bitrix\Location\Controller\Address\deleteAction
deleteAction(int $addressId)
Definition
address.php:84
Bitrix\Location\Controller\Address\findById
findById(int $addressId)
Definition
address.php:35
Bitrix\Location\Controller\Address\saveAction
static saveAction(array $address)
Definition
address.php:67
Bitrix\Location\Controller\Address\createArrayFromAddressCollection
createArrayFromAddressCollection(array $collection)
Definition
address.php:51
Bitrix\Location\Entity\Address\Converter\ArrayConverter
Definition
arrayconverter.php:14
Bitrix\Location\Infrastructure\Service\ErrorService
Definition
errorservice.php:21
Bitrix\Main\Engine\ActionFilter\Cors
Definition
cors.php:13
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\ORM\Data\DeleteResult
Definition
deleteresult.php:12
Bitrix\Location\Controller
Definition
address.php:3
Bitrix\Location\Service
Definition
addressservice.php:3
Bitrix
modules
location
lib
controller
address.php
Создано системой
1.10.0