Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
recentitem.php
1<?php
2
4
5class RecentItem implements \JsonSerializable
6{
7 protected $id;
8 protected $entityId;
9 protected $lastUseDate;
10 protected $loaded = false;
11 protected $available = true;
12
13 public function __construct(array $options)
14 {
15 $id = $options['id'] ?? null;
16 if ((is_string($id) && $id !== '') || is_int($id))
17 {
18 $id = (string)(int)$id === $id ? (int)$id : $id;
19 $this->id = $id;
20 }
21
22 $entityId = $options['entityId'] ?? null;
23 if (is_string($entityId) && $entityId !== '')
24 {
25 $this->entityId = strtolower($entityId);
26 }
27
28 if (isset($options['loaded']) && is_bool($options['loaded']))
29 {
30 $this->setLoaded($options['loaded']);
31 }
32
33 if (isset($options['available']) && is_bool($options['available']))
34 {
35 $this->setAvailable($options['available']);
36 }
37
38 if (isset($options['lastUseDate']) && is_int($options['lastUseDate']))
39 {
40 $this->setLastUseDate($options['lastUseDate']);
41 }
42 }
43
44 public function getId()
45 {
46 return $this->id;
47 }
48
49 public function getEntityId(): string
50 {
51 return $this->entityId;
52 }
53
54 public function getLastUseDate(): ?int
55 {
56 return $this->lastUseDate;
57 }
58
59 public function setLastUseDate(int $lastUseDate): self
60 {
61 $this->lastUseDate = $lastUseDate;
62
63 return $this;
64 }
65
66 public function isLoaded(): bool
67 {
68 return $this->loaded;
69 }
70
71 public function setLoaded(bool $flag): self
72 {
73 $this->loaded = $flag;
74
75 return $this;
76 }
77
78 public function isAvailable(): bool
79 {
80 return $this->available;
81 }
82
83 public function setAvailable(bool $flag): self
84 {
85 $this->available = $flag;
86
87 return $this;
88 }
89
90 public function jsonSerialize()
91 {
92 return [$this->getEntityId(), $this->getId()];
93 }
94}