1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
PinCollection.php
См. документацию.
1<?php
2
4
7use Bitrix\Im\V2\Common\SidebarFilterProcessorTrait;
18
24{
25 use SidebarFilterProcessorTrait;
26
27 public static function find(
29 array $order = ['ID' => 'DESC'],
30 ?int $limit = null,
31 ?Context $context = null
32 ): self
33 {
34 $context = $context ?? Locator::getContext();
35
36 $pinOrder = ['ID' => 'DESC'];
37
38 if (isset($order['ID']))
39 {
40 $pinOrder['ID'] = $order['ID'];
41 }
42
43 $query = LinkPinTable::query()
44 ->setSelect(['ID', 'CHAT_ID', 'AUTHOR_ID', 'DATE_CREATE', 'MESSAGE_ID'])
45 ->setOrder($pinOrder)
46 ;
47 if (isset($limit))
48 {
49 $query->setLimit($limit);
50 }
51
52 static::processFilters($query, $filter, $pinOrder);
53
54 return static::initByEntityCollection($query->fetchCollection());
55 }
56
57 public static function initByEntityCollection(EO_LinkPin_Collection $entityCollection): self
58 {
59 $pinCollection = new static();
60
61 foreach ($entityCollection as $entity)
62 {
63 $pinCollection[] = PinItem::initByEntity($entity);
64 }
65
66 return $pinCollection;
67 }
68
69 public static function getByMessages(MessageCollection $messages): self
70 {
71 $entities = LinkPinTable::query()
72 ->setSelect(['ID', 'CHAT_ID', 'AUTHOR_ID', 'DATE_CREATE', 'MESSAGE_ID'])
73 ->whereIn('MESSAGE_ID', $messages->getIds())
74 ->fetchCollection()
75 ;
76
77 if ($entities === null)
78 {
79 return new static();
80 }
81
82 $links = static::initByEntityCollection($entities);
83
84 foreach ($links as $link)
85 {
86 $messageId = $link->getMessageId();
87
88 if (!isset($messageId))
89 {
90 continue;
91 }
92
93 $link->setEntity($messages[$messageId]);
94 }
95
96 return $links;
97 }
98
99 public static function getCollectionElementClass(): string
100 {
101 return PinItem::class;
102 }
103
104 public static function getRestEntityName(): string
105 {
106 return 'pins';
107 }
108
109 protected static function processFilters(Query $query, array $filter, array $order): void
110 {
111 static::processSidebarFilters($query, $filter, $order);
112 }
113
114 public function getAuthorIds(): array
115 {
116 $authorIds = [];
117 foreach ($this as $item)
118 {
119 $authorIds[$item->getAuthorId()] = $item->getAuthorId();
120 }
121
122 return $authorIds;
123 }
124
125 public function getMessageIds(): array
126 {
127 $messageIds = [];
128 foreach ($this as $item)
129 {
130 $messageIds[$item->getMessageId()] = $item->getMessageId();
131 }
132
133 return $messageIds;
134 }
135}
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
</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
Определения culture.php:9
Определения chain.php:3
$order
Определения payment.php:8
$messages
Определения template.php:8