Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
preselecteditem.php
1<?php
2
4
5class PreselectedItem implements \JsonSerializable
6{
7 protected $id;
8 protected $entityId;
9 protected $item;
10
11 public function __construct(array $options)
12 {
13 $id = $options['id'] ?? null;
14 if ((is_string($id) && $id !== '') || is_int($id))
15 {
16 $this->id = $id;
17 }
18
19 $entityId = $options['entityId'] ?? null;
20 if (is_string($entityId) && $entityId !== '')
21 {
22 $this->entityId = strtolower($entityId);
23 }
24 }
25
26 public function getId()
27 {
28 return $this->id;
29 }
30
31 public function getEntityId(): string
32 {
33 return $this->entityId;
34 }
35
36 public function setItem(Item $item)
37 {
38 $this->item = $item;
39 }
40
41 public function getItem(): ?Item
42 {
43 return $this->item;
44 }
45
46 public function isLoaded()
47 {
48 return $this->getItem() !== null;
49 }
50
51 public function jsonSerialize()
52 {
53 return [$this->getEntityId(), $this->getId()];
54 }
55}