1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RecentItem.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Recent;
4
5use Bitrix\Im\Model\EO_Recent;
6use Bitrix\Im\V2\Chat;
7use Bitrix\Im\V2\Rest\RestConvertible;
8use Bitrix\Main\Type\DateTime;
9
11{
12 protected string $dialogId;
13 protected int $chatId;
14 protected int $messageId;
15 protected int $id = 0;
16 protected RecentType $type = RecentType::Chat;
17 protected int $counter = 0;
18 protected int $lastReadMessageId = 0;
19 protected int $markedId = 0;
20 protected bool $pinned = false;
21 protected bool $unread = false;
22 protected ?DateTime $dateUpdate = null;
23 protected ?DateTime $dateLastActivity = null;
24 protected array $options = [];
25 protected array $invited = [];
26
27 public static function initByEntity(EO_Recent $entity): self
28 {
29 $recentItem = new static();
30
31 $recentItem->dialogId = static::formDialogId($entity->getItemId(), $entity->getItemType());
32 $recentItem->chatId = $entity->getItemCid();
33 $recentItem->messageId = $entity->getItemMid();
34 $recentItem->id = $entity->getItemId() ?? 0;
35 $recentItem->type = RecentType::tryFromChatType($entity->getItemType());
36 $recentItem->pinned = $entity->getPinned();
37 $recentItem->unread = $entity->getUnread();
38
39 return $recentItem;
40 }
41
42 public function getDialogId(): string
43 {
44 return $this->dialogId;
45 }
46
47 public function setDialogId(string $dialogId): RecentItem
48 {
49 $this->dialogId = $dialogId;
50 return $this;
51 }
52
53 public function getChatId(): int
54 {
55 return $this->chatId;
56 }
57
58 public function setChatId(int $chatId): RecentItem
59 {
60 $this->chatId = $chatId;
61 return $this;
62 }
63
64 public function getMessageId(): int
65 {
66 return $this->messageId;
67 }
68
69 public function setMessageId(int $messageId): RecentItem
70 {
71 $this->messageId = $messageId;
72 return $this;
73 }
74
75 public function getId(): int
76 {
77 return $this->id;
78 }
79
80 public function setId(int $id): RecentItem
81 {
82 $this->id = $id;
83 return $this;
84 }
85
86 public function getType(): RecentType
87 {
88 return $this->type;
89 }
90
92 {
93 $this->type = $type;
94 return $this;
95 }
96
97 public function isPinned(): bool
98 {
99 return $this->pinned;
100 }
101
102 public function setPinned(bool $pinned): RecentItem
103 {
104 $this->pinned = $pinned;
105 return $this;
106 }
107
108 public function isUnread(): bool
109 {
110 return $this->unread;
111 }
112
113 public function setUnread(bool $unread): RecentItem
114 {
115 $this->unread = $unread;
116 return $this;
117 }
118
119 public function getOptions(): array
120 {
121 return $this->options;
122 }
123
125 {
126 $this->options = $options;
127 return $this;
128 }
129
130 public function getInvited(): array
131 {
132 return $this->invited;
133 }
134
136 {
137 $this->invited = $invited;
138 return $this;
139 }
140
141 public function getCounter(): int
142 {
143 return $this->counter;
144 }
145
146 public function setCounter(int $counter): RecentItem
147 {
148 $this->counter = $counter;
149 return $this;
150 }
151
152 public function getLastReadMessageId(): int
153 {
155 }
156
158 {
159 $this->lastReadMessageId = $lastReadMessageId;
160 return $this;
161 }
162
163 public function getDateUpdate(): ?DateTime
164 {
165 return $this->dateUpdate;
166 }
167
169 {
170 $this->dateUpdate = $dateUpdate;
171 return $this;
172 }
173
174 public function getDateLastActivity(): ?DateTime
175 {
177 }
178
180 {
181 $this->dateLastActivity = $dateLastActivity;
182 return $this;
183 }
184
185 public function getMarkedId(): int
186 {
187 return $this->markedId;
188 }
189
190 public function setMarkedId(int $markedId): self
191 {
192 $this->markedId = $markedId;
193 return $this;
194 }
195
196 protected static function formDialogId(int $id, string $type): string
197 {
198 if ($type === Chat::IM_TYPE_PRIVATE)
199 {
200 return (string)$id;
201 }
202
203 return "chat{$id}";
204 }
205
206 public static function getRestEntityName(): string
207 {
208 return 'recentItem';
209 }
210
211 public function toRestFormat(array $option = []): array
212 {
213 return [
214 'dialogId' => $this->dialogId,
215 'chatId' => $this->chatId,
216 'messageId' => $this->messageId,
217 'type' => $this->type,
218 'pinned' => $this->pinned,
219 'unread' => $this->unread,
220 'options' => $this->options,
221 'invited' => $this->invited,
222 'lastReadMessageId' => $this->lastReadMessageId,
223 'counter' => $this->counter,
224 'dateUpdate' => $this->dateUpdate,
225 'dateLastActivity' => $this->dateLastActivity,
226 ];
227 }
228}
static getRestEntityName()
Определения RecentItem.php:206
int $lastReadMessageId
Определения RecentItem.php:18
setDialogId(string $dialogId)
Определения RecentItem.php:47
toRestFormat(array $option=[])
Определения RecentItem.php:211
DateTime $dateUpdate
Определения RecentItem.php:22
setDateUpdate(?DateTime $dateUpdate)
Определения RecentItem.php:168
RecentType $type
Определения RecentItem.php:16
setDateLastActivity(?DateTime $dateLastActivity)
Определения RecentItem.php:179
setOptions(array $options)
Определения RecentItem.php:124
static formDialogId(int $id, string $type)
Определения RecentItem.php:196
string $dialogId
Определения RecentItem.php:12
DateTime $dateLastActivity
Определения RecentItem.php:23
setMarkedId(int $markedId)
Определения RecentItem.php:190
setInvited(array $invited)
Определения RecentItem.php:135
static initByEntity(EO_Recent $entity)
Определения RecentItem.php:27
setMessageId(int $messageId)
Определения RecentItem.php:69
setUnread(bool $unread)
Определения RecentItem.php:113
setType(RecentType $type)
Определения RecentItem.php:91
setChatId(int $chatId)
Определения RecentItem.php:58
setLastReadMessageId(int $lastReadMessageId)
Определения RecentItem.php:157
setPinned(bool $pinned)
Определения RecentItem.php:102
setId(int $id)
Определения RecentItem.php:80
setCounter(int $counter)
Определения RecentItem.php:146
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity
RecentType
Определения RecentType.php:10
@ tryFromChatType
Определения RecentType.php:14
$option
Определения options.php:1711