1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
EntityCollection.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Entity;
4
5use Bitrix\Im\V2\Common\ContextCustomer;
6use Bitrix\Im\V2\Registry;
7use Bitrix\Im\V2\Rest\PopupData;
8use Bitrix\Im\V2\Rest\PopupDataAggregatable;
9use Bitrix\Im\V2\Rest\RestConvertible;
10use Bitrix\Im\V2\Rest\RestEntity;
11
17{
18 use ContextCustomer;
19
20 protected array $entitiesWithId = [];
21
22 public function getPopupData(array $excludedList = []): PopupData
23 {
24 $data = new PopupData([], $excludedList);
25
26 foreach ($this as $entity)
27 {
28 $data->mergeFromEntity($entity, $excludedList);
29 }
30
31 return $data;
32 }
33
37 public function getUnique(): self
38 {
39 return static::initByArray($this->entitiesWithId);
40 }
41
42 public function getIds(): array
43 {
44 $ids = [];
45
46 foreach ($this as $entity)
47 {
48 $ids[$entity->getId()] = $entity->getId();
49 }
50
51 return $ids;
52 }
53
54 public function getById(int $id): ?RestEntity
55 {
56 return $this->entitiesWithId[$id] ?? null;
57 }
58
59 public function toRestFormat(array $option = []): array
60 {
61 $collection = [];
62 $idsAsKey = $option['IDS_AS_KEY'] ?? false;
63
64 foreach ($this as $entity)
65 {
66 if ($idsAsKey)
67 {
68 $collection[$entity->getId()] = $entity->toRestFormat($option);
69 }
70 else
71 {
72 $collection[] = $entity->toRestFormat($option);
73 }
74 }
75
76 return $collection;
77 }
78
83 public static function initByArray(array $entities): self
84 {
85 $collection = new static();
86
87 foreach ($entities as $entity)
88 {
89 $collection[] = $entity;
90 }
91
92 return $collection;
93 }
94
95 //region Collection interface
96
97 public function offsetSet($offset, $value): void
98 {
99 if ($offset === null)
100 {
101 if ($value->getId() !== null)
102 {
103 $this->entitiesWithId[$value->getId()] = $value;
104 }
105 }
106
107 parent::offsetSet($offset, $value);
108 }
109
110 //endregion
111}
static initByArray(array $entities)
Определения EntityCollection.php:83
toRestFormat(array $option=[])
Определения EntityCollection.php:59
getPopupData(array $excludedList=[])
Определения EntityCollection.php:22
offsetSet($offset, $value)
Определения EntityCollection.php:97
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity
$option
Определения options.php:1711