1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ChatPopupItem.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Chat;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Im\V2\Common\ContextCustomer;
7use Bitrix\Im\V2\Rest\PopupDataItem;
8
10{
11 use ContextCustomer;
12
16 protected array $chats = [];
17 protected ?array $chatIds = null;
18
22 public function __construct(array $chats)
23 {
24 foreach ($chats as $chat)
25 {
26 $this->chats[$chat->getChatId()] = $chat;
27 }
28 }
29
30 public function merge(PopupDataItem $item): PopupDataItem
31 {
32 return $this;
33 }
34
35 public static function getRestEntityName(): string
36 {
37 return 'chats';
38 }
39
40 public function toRestFormat(array $option = []): array
41 {
42 $rest = [];
43
44 Chat::fillSelfRelations($this->chats);
45 $this->fillDialogIds();
46
47 foreach ($this->chats as $chat)
48 {
49 $rest[] = $chat->toRestFormat(['CHAT_SHORT_FORMAT' => true]);
50 }
51
52 return $rest;
53 }
54
55 protected function fillDialogIds(): void
56 {
57 $privateChatIds = [];
58 foreach ($this->chats as $chat)
59 {
60 if ($chat instanceof PrivateChat && !$chat->hasDialogId())
61 {
62 $privateChatIds[] = $chat->getChatId();
63 }
64 }
65
66 $dialogIds = PrivateChat::getDialogIds($privateChatIds, $this->getContext()->getUserId());
67
68 foreach ($dialogIds as $chatId => $dialogId)
69 {
70 $this->chats[$chatId]?->setDialogId($dialogId);
71 }
72 }
73
74 protected function getChatIds(): array
75 {
76 if ($this->chatIds === null)
77 {
78 foreach ($this->chats as $chat)
79 {
80 $this->chatIds[] = $chat->getChatId();
81 }
82 }
83
84 return $this->chatIds ?? [];
85 }
86}
static getRestEntityName()
Определения ChatPopupItem.php:35
__construct(array $chats)
Определения ChatPopupItem.php:22
toRestFormat(array $option=[])
Определения ChatPopupItem.php:40
merge(PopupDataItem $item)
Определения ChatPopupItem.php:30
static getDialogIds(array $chatIds, int $contextUserId)
Определения PrivateChat.php:585
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$option
Определения options.php:1711