1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
FavoriteCollection.php
См. документацию.
1<?php
2
4
7use Bitrix\Im\V2\Common\SidebarFilterProcessorTrait;
17
23{
24 use SidebarFilterProcessorTrait;
25
26 public static function getCollectionElementClass(): string
27 {
28 return FavoriteItem::class;
29 }
30
31 public static function find(
32 array $filter = [],
33 array $order = ['ID' => 'DESC'],
34 ?int $limit = null,
35 ?Context $context = null
36 ): self
37 {
38 $context = $context ?? Locator::getContext();
39
40 $messageOrder = ['ID' => 'DESC'];
41
42 if (isset($order['ID']))
43 {
44 $messageOrder['ID'] = $order['ID'];
45 }
46
47 $query = LinkFavoriteTable::query()
48 ->setSelect(['MESSAGE', 'ID', 'CHAT_ID', 'AUTHOR_ID', 'DATE_CREATE', 'MESSAGE_ID'])
49 ->where('AUTHOR_ID', $context->getUserId())
50 ->setOrder($messageOrder)
51 ;
52 if (isset($limit))
53 {
54 $query->setLimit($limit);
55 }
56 static::processFilters($query, $filter, $messageOrder);
57
58 return static::initByEntityCollection($query->fetchCollection());
59 }
60
61 public static function initByEntityCollection(EO_LinkFavorite_Collection $entityCollection): self
62 {
63 $favoriteMessageCollection = new static();
64
65 foreach ($entityCollection as $entity)
66 {
67 $favoriteMessageCollection[] = FavoriteItem::initByEntity($entity);
68 }
69
70 return $favoriteMessageCollection;
71 }
72
73 public static function getByMessage(Message $message): self
74 {
75 $entities = LinkFavoriteTable::query()
76 ->setSelect(['ID', 'CHAT_ID', 'AUTHOR_ID', 'DATE_CREATE', 'MESSAGE_ID'])
77 ->where('MESSAGE_ID', $message->getMessageId())
78 ->fetchCollection()
79 ;
80
81 if ($entities === null)
82 {
83 return new static();
84 }
85
86 $links = static::initByEntityCollection($entities);
87
88 foreach ($links as $link)
89 {
90 $link->setEntity($message);
91 }
92
93 return $links;
94 }
95
96 public static function getByMessages(MessageCollection $messages): self
97 {
98 $entities = LinkFavoriteTable::query()
99 ->setSelect(['ID', 'CHAT_ID', 'AUTHOR_ID', 'DATE_CREATE', 'MESSAGE_ID'])
100 ->whereIn('MESSAGE_ID', $messages->getIds())
101 ->fetchCollection()
102 ;
103
104 if ($entities === null)
105 {
106 return new static();
107 }
108
109 $links = static::initByEntityCollection($entities);
110
111 foreach ($links as $link)
112 {
113 $messageId = $link->getMessageId();
114
115 if (!isset($messageId))
116 {
117 continue;
118 }
119
120 $link->setEntity($messages[$messageId]);
121 }
122
123 return $links;
124 }
125
127 {
128 $messageCollection = new MessageCollection();
129
130 foreach ($this as $favoriteMessage)
131 {
132 $messageCollection->add($favoriteMessage->getEntity());
133 }
134
135 return $messageCollection;
136 }
137
138 public function getPopupData(array $excludedList = []): PopupData
139 {
140 $messages = $this->getMessageCollection()->fillAllForRest();
141 $data = new PopupData([
144 //new ReminderPopupItem($messages->getReminders())
145 ], $excludedList);
146 $excludedList[] = ReminderPopupItem::class;
147
148 return $data->merge(parent::getPopupData($excludedList));
149 }
150
151 public function toRestFormat(array $option = []): array
152 {
153 $this->getMessageCollection()->fillAllForRest();
154
155 return parent::toRestFormat($option);
156 }
157
158 protected static function processFilters(Query $query, array $filter, array $order): void
159 {
160 static::processSidebarFilters(
161 $query,
162 $filter,
163 $order,
164 ['AUTHOR_ID' => 'MESSAGE.AUTHOR_ID', 'DATE_CREATE' => 'MESSAGE.DATE_CREATE']
165 );
166
167 if (isset($filter['SEARCH_MESSAGE']))
168 {
169 $query->whereLike('MESSAGE.MESSAGE', "%{$filter['SEARCH_MESSAGE']}%");
170 }
171 }
172}
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11
$entity
$filter
Определения iblock_catalog_list.php:54
$context
Определения csv_new_setup.php:223
Определения Uuid.php:3
Определения culture.php:9
Определения ufield.php:9
Определения Image.php:9
Определения chain.php:3
$order
Определения payment.php:8
$message
Определения payment.php:8
$messages
Определения template.php:8
$option
Определения options.php:1711