Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
PopupData.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Rest
;
4
5
class
PopupData
6
{
10
protected
array
$popupItems
= [];
11
protected
array
$excludedList
= [];
12
17
public
function
__construct
(array $popupDataItems, array
$excludedList
= [])
18
{
19
foreach
($popupDataItems as $popupDataItem)
20
{
21
$this->
add
($popupDataItem);
22
}
23
$this->excludedList =
$excludedList
;
24
$this->filterItems(
$excludedList
);
25
}
26
27
public
function
merge
(
self
$popupData): self
28
{
29
foreach
($popupData->popupItems as $popupItem)
30
{
31
$this->mergeItem($popupItem);
32
}
33
34
return
$this;
35
}
36
37
public
function
add
(
PopupDataItem
$item): self
38
{
39
$this->mergeItem($item);
40
41
return
$this;
42
}
43
44
public
function
mergeFromEntity
(
RestConvertible
$entity, array
$excludedList
= []): self
45
{
46
if
($entity instanceof
PopupDataAggregatable
)
47
{
48
return
$this->
merge
($entity->getPopupData(
$excludedList
));
49
}
50
51
return
$this;
52
}
53
54
public
function
toRestFormat
(array $options = []): array
55
{
56
$result = [];
57
58
foreach
($this->popupItems as $item)
59
{
60
if
($item instanceof
PopupDataAggregatable
)
61
{
62
$this->
merge
($item->getPopupData($this->excludedList));
63
}
64
}
65
66
foreach
($this->popupItems as $item)
67
{
68
$result[$item::getRestEntityName()] = $item->toRestFormat($options);
69
}
70
71
return
$result;
72
}
73
74
private
function
mergeItem(
PopupDataItem
$popupItem): void
75
{
76
if
(!isset($this->popupItems[$popupItem::getRestEntityName()]))
77
{
78
$this->popupItems[$popupItem::getRestEntityName()] = $popupItem;
79
}
80
else
81
{
82
$this->popupItems[$popupItem::getRestEntityName()]->
merge
($popupItem);
83
}
84
}
85
90
private
function
filterItems(array
$excludedList
): void
91
{
92
foreach
(
$excludedList
as $excludedItem)
93
{
94
unset($this->popupItems[$excludedItem::getRestEntityName()]);
95
}
96
}
97
}
Bitrix\Im\V2\Rest\PopupData
Definition
PopupData.php:6
Bitrix\Im\V2\Rest\PopupData\$popupItems
array $popupItems
Definition
PopupData.php:10
Bitrix\Im\V2\Rest\PopupData\__construct
__construct(array $popupDataItems, array $excludedList=[])
Definition
PopupData.php:17
Bitrix\Im\V2\Rest\PopupData\mergeFromEntity
mergeFromEntity(RestConvertible $entity, array $excludedList=[])
Definition
PopupData.php:44
Bitrix\Im\V2\Rest\PopupData\toRestFormat
toRestFormat(array $options=[])
Definition
PopupData.php:54
Bitrix\Im\V2\Rest\PopupData\$excludedList
array $excludedList
Definition
PopupData.php:11
Bitrix\Im\V2\Rest\PopupData\add
add(PopupDataItem $item)
Definition
PopupData.php:37
Bitrix\Im\V2\Rest\PopupData\merge
merge(self $popupData)
Definition
PopupData.php:27
Bitrix\Im\V2\Rest\PopupDataAggregatable
Definition
PopupDataAggregatable.php:10
Bitrix\Im\V2\Rest\PopupDataItem
Definition
PopupDataItem.php:6
Bitrix\Im\V2\Rest\PopupDataItem\merge
merge(self $item)
Bitrix\Im\V2\Rest\RestConvertible
Definition
RestConvertible.php:6
Bitrix\Im\V2\Rest
Definition
PopupData.php:3
modules
im
lib
V2
Rest
PopupData.php
Создано системой
1.10.0