1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
ChatPopupItem.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Chat;
4
5
use Bitrix\Im\V2\Chat;
6
use Bitrix\Im\V2\Common\ContextCustomer;
7
use Bitrix\Im\V2\Rest\PopupDataItem;
8
9
class
ChatPopupItem
implements
PopupDataItem
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
}
Bitrix\Im\V2\Chat\ChatPopupItem
Определения
ChatPopupItem.php:10
Bitrix\Im\V2\Chat\ChatPopupItem\getRestEntityName
static getRestEntityName()
Определения
ChatPopupItem.php:35
Bitrix\Im\V2\Chat\ChatPopupItem\__construct
__construct(array $chats)
Определения
ChatPopupItem.php:22
Bitrix\Im\V2\Chat\ChatPopupItem\toRestFormat
toRestFormat(array $option=[])
Определения
ChatPopupItem.php:40
Bitrix\Im\V2\Chat\ChatPopupItem\$chatIds
array $chatIds
Определения
ChatPopupItem.php:17
Bitrix\Im\V2\Chat\ChatPopupItem\$chats
array $chats
Определения
ChatPopupItem.php:16
Bitrix\Im\V2\Chat\ChatPopupItem\fillDialogIds
fillDialogIds()
Определения
ChatPopupItem.php:55
Bitrix\Im\V2\Chat\ChatPopupItem\getChatIds
getChatIds()
Определения
ChatPopupItem.php:74
Bitrix\Im\V2\Chat\ChatPopupItem\merge
merge(PopupDataItem $item)
Определения
ChatPopupItem.php:30
Bitrix\Im\V2\Chat\PrivateChat
Определения
PrivateChat.php:33
Bitrix\Im\V2\Chat\PrivateChat\getDialogIds
static getDialogIds(array $chatIds, int $contextUserId)
Определения
PrivateChat.php:585
Bitrix\Im\V2\Chat\PrivateChat\hasDialogId
hasDialogId()
Определения
PrivateChat.php:105
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Im\V2\Rest\PopupDataItem
Определения
PopupDataItem.php:6
$option
$option
Определения
options.php:1711
bitrix
modules
im
lib
V2
Chat
ChatPopupItem.php
Создано системой
1.14.0