1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
arrayconverter.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Location\Entity\Address\Converter
;
4
5
use
Bitrix\Location\Entity\Address
;
6
use
Bitrix\Location\Entity\Location
;
7
13
final
class
ArrayConverter
14
{
22
public
static
function
convertToArray
(
Address
$address,
bool
$convertLocation =
true
):
array
23
{
24
$result
= [
25
'id'
=> $address->
getId
(),
26
'latitude'
=> $address->
getLatitude
(),
27
'longitude'
=> $address->
getLongitude
(),
28
'languageId'
=> $address->
getLanguageId
(),
29
'fieldCollection'
=>
self::convertFieldsToArray
($address->
getAllFieldsValues
()),
30
'links'
=>
self::convertLinksToArray
($address)
31
];
32
33
if
($convertLocation &&
$location
= $address->
getLocation
())
34
{
35
$result
[
'location'
] =
Location\Converter\ArrayConverter::convertToArray
(
$location
);
36
}
37
38
return
$result
;
39
}
40
47
public
static
function
convertFromArray
(
array
$data
):
Address
48
{
49
$languageId = (string)(
$data
[
'languageId'
] ??
''
);
50
51
$result
=
new
Address
($languageId);
52
53
if
(isset(
$data
[
'id'
]))
54
{
55
$result
->setId((
int
)
$data
[
'id'
]);
56
}
57
58
if
(isset(
$data
[
'latitude'
]))
59
{
60
$result
->setLatitude((
string
)
$data
[
'latitude'
]);
61
}
62
63
if
(isset(
$data
[
'longitude'
]))
64
{
65
$result
->setLongitude((
string
)
$data
[
'longitude'
]);
66
}
67
68
if
(isset(
$data
[
'fieldCollection'
]) && is_array(
$data
[
'fieldCollection'
]))
69
{
70
foreach
(
$data
[
'fieldCollection'
] as $itemType => $itemValue)
71
{
72
$result
->setFieldValue((
int
)$itemType, (
string
)$itemValue);
73
}
74
}
75
76
if
(isset(
$data
[
'links'
]) && is_array(
$data
[
'links'
]))
77
{
78
foreach
(
$data
[
'links'
] as $link)
79
{
80
$result
->addLink((
string
)$link[
'entityId'
], (
string
)$link[
'entityType'
]);
81
}
82
}
83
84
if
(isset(
$data
[
'location'
]) && is_array(
$data
[
'location'
]))
85
{
86
if
(
$location
= Location::fromArray(
$data
[
'location'
]))
87
{
88
$result
->setLocation(
$location
);
89
}
90
}
91
92
return
$result
;
93
}
94
99
protected
static
function
convertFieldsToArray
(
array
$fieldsValues):
array
100
{
101
$result
= [];
102
103
foreach
($fieldsValues as
$type
=> $value)
104
{
105
$result
[
$type
] = $value;
106
}
107
108
return
$result
;
109
}
110
115
protected
static
function
convertLinksToArray
(
Address
$address):
array
116
{
117
$result
= [];
118
119
foreach
($address->
getLinks
() as $link)
120
{
121
$result
[] = [
122
'entityId'
=> $link->getAddressLinkEntityId(),
123
'entityType'
=> $link->getAddressLinkEntityType(),
124
];
125
}
126
127
return
$result
;
128
}
129
}
$type
$type
Определения
options.php:106
Bitrix\Location\Entity\Address\Converter\ArrayConverter
Определения
arrayconverter.php:14
Bitrix\Location\Entity\Address\Converter\ArrayConverter\convertFieldsToArray
static convertFieldsToArray(array $fieldsValues)
Определения
arrayconverter.php:99
Bitrix\Location\Entity\Address\Converter\ArrayConverter\convertLinksToArray
static convertLinksToArray(Address $address)
Определения
arrayconverter.php:115
Bitrix\Location\Entity\Address\Converter\ArrayConverter\convertFromArray
static convertFromArray(array $data)
Определения
arrayconverter.php:47
Bitrix\Location\Entity\Address\Converter\ArrayConverter\convertToArray
static convertToArray(Address $address, bool $convertLocation=true)
Определения
arrayconverter.php:22
Bitrix\Location\Entity\Address\getLinks
getLinks()
Определения
address.php:314
Bitrix\Location\Entity\Address\getId
getId()
Определения
address.php:52
Bitrix\Location\Entity\Address\getLocation
getLocation()
Определения
address.php:135
Bitrix\Location\Entity\Address\getAllFieldsValues
getAllFieldsValues()
Определения
address.php:179
Bitrix\Location\Entity\Address\getLanguageId
getLanguageId()
Определения
address.php:106
Bitrix\Location\Entity\Address\getLongitude
getLongitude()
Определения
address.php:88
Bitrix\Location\Entity\Address\getLatitude
getLatitude()
Определения
address.php:70
Bitrix\Location\Entity\Location\Converter\ArrayConverter\convertToArray
static convertToArray(Entity\Location $location)
Определения
arrayconverter.php:21
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
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
Bitrix\Location\Entity\Address\Converter
Определения
arrayconverter.php:3
Bitrix\Location\Entity\Address
Определения
addresscollection.php:3
Bitrix\Location\Entity\Location
Определения
collection.php:3
$location
$location
Определения
options.php:2729
bitrix
modules
location
lib
entity
address
converter
arrayconverter.php
Создано системой
1.14.0