1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Entities.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Sync;
4
5use Bitrix\Im\V2\MessageCollection;
6use Bitrix\Im\V2\Rest\RestAdapter;
7use Bitrix\Im\V2\Sync\Entity\Chats;
8use Bitrix\Im\V2\Sync\Entity\DialogIds;
9use Bitrix\Im\V2\Sync\Entity\Messages;
10use Bitrix\Im\V2\Sync\Entity\PinMessages;
11use Bitrix\Im\V2\Chat\Comment\CommentPopupItem;
12use Bitrix\Im\V2\TariffLimit\TariffLimitPopupItem;
13
15{
16 protected array $rest = [];
17
18 public function __construct(
19 protected Chats $chats,
20 protected Messages $messages,
21 protected PinMessages $pinMessages,
22 protected DialogIds $dialogIds,
23 )
24 {}
25
26 public function getRestData(): array
27 {
28 $this->loadRestData();
29 $this->rest['dialogIds'] = $this->fillRestDialogData();
30
31 return $this->rest;
32 }
33
34 protected function loadRestData(): void
35 {
36 $this->rest[Chats::getRestEntityName()] = $this->chats->toRestFormat();
37 $this->rest[Messages::getRestEntityName()] = $this->messages->toRestFormat();
38 $this->rest[PinMessages::getRestEntityName()] = $this->pinMessages->toRestFormat();
39
40 $messageCollection = $this->getMessageCollection();
41 $pinCollection = $this->pinMessages->getPinCollection();
42 $chatItems = $this->chats->getChatItems();
43
44 $restData = (new RestAdapter($messageCollection, $pinCollection, $chatItems))->toRestFormat($this->getOption());
45 $this->rest = array_merge($this->rest, $restData);
46 }
47
48 protected function getOption(): array
49 {
50 return [
51 'POPUP_DATA_EXCLUDE' => [CommentPopupItem::class, TariffLimitPopupItem::class]
52 ];
53 }
54
56 {
57 $messageIds = $this->messages->getMessageIds() + $this->chats->getMessageIds();
58
59 return (new MessageCollection($messageIds));
60 }
61
62 protected function fillRestDialogData(): array
63 {
64 return $this->dialogIds->load($this->rest)->toRestFormat();
65 }
66}
getOption()
Определения Entities.php:48
__construct(protected Chats $chats, protected Messages $messages, protected PinMessages $pinMessages, protected DialogIds $dialogIds,)
Определения Entities.php:18
array $rest
Определения Entities.php:16
fillRestDialogData()
Определения Entities.php:62
loadRestData()
Определения Entities.php:34
getMessageCollection()
Определения Entities.php:55
getRestData()
Определения Entities.php:26
static getRestEntityName()
Определения Chats.php:121
static getRestEntityName()
Определения Messages.php:47
static getRestEntityName()
Определения PinMessages.php:36
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$messages
Определения template.php:8