Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Reaction.php
1<?php
2
4
9
11{
15 public function addAction(Message $message, string $reaction): ?array
16 {
17 $reaction = mb_strtoupper($reaction);
18 $service = new ReactionService($message);
19 $reactResult = $service->addReaction($reaction);
20
21 if (!$reactResult->isSuccess())
22 {
23 $this->addErrors($reactResult->getErrors());
24
25 return null;
26 }
27
28 return [];
29 }
30
34 public function deleteAction(Message $message, string $reaction): ?array
35 {
36 $reaction = mb_strtoupper($reaction);
37 $service = new ReactionService($message);
38 $reactResult = $service->deleteReaction($reaction);
39
40 if (!$reactResult->isSuccess())
41 {
42 $this->addErrors($reactResult->getErrors());
43
44 return null;
45 }
46
47 return [];
48 }
49
53 public function tailAction(Message $message, array $filter = [], array $order = [], int $limit = 50): ?array
54 {
55 $reaction = $filter['reaction'] ?? null;
56 if ($reaction !== null)
57 {
58 $reaction = mb_strtoupper($reaction);
59 $validateResult = Message\Reaction\ReactionItem::validateReaction($reaction);
60 if (!$validateResult->isSuccess())
61 {
62 $this->addErrors($validateResult->getErrors());
63
64 return null;
65 }
66 }
67
68 $reactionFilter = [
69 'LAST_ID' => $filter['lastId'] ?? null,
70 'MESSAGE_ID' => $message->getMessageId(),
71 'REACTION' => $reaction,
72 ];
73 $reactionOrder = [
74 'ID' => $order['id'] ?? 'DESC'
75 ];
76 $reactionLimit = $this->getLimit($limit);
77
78 $reactions = Message\Reaction\ReactionCollection::find($reactionFilter, $reactionOrder, $reactionLimit);
79
80 return (new RestAdapter($reactions))->toRestFormat();
81 }
82}
addAction(Message $message, string $reaction)
Definition Reaction.php:15
deleteAction(Message $message, string $reaction)
Definition Reaction.php:34
tailAction(Message $message, array $filter=[], array $order=[], int $limit=50)
Definition Reaction.php:53