1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
BaseEvent.php
См. документацию.
1<?php
2
4
9
10abstract class BaseEvent implements Event
11{
12 protected int $expiry;
13 protected Sender $sender;
14 protected string $moduleId = 'im';
16 private array $wrappingParameters;
17
18 public function __construct()
19 {
20 $this->sender = Locator::getPullSender();
21 }
22
23 final public function send(): Result
24 {
25 return $this->sender->send($this);
26 }
27
28 final public function getBase(): array
29 {
30 return $this->wrapPullParams($this->getBasePullParams());
31 }
32
36 final public function getPullByUsers(): array
37 {
38 $pullByUsers = [];
39 $pullParamsByUsers = $this->getPullParamsByUsers();
40
41 foreach ($pullParamsByUsers as $group)
42 {
43 $pullByUsers[] = new Group($group->getRecipients(), $this->wrapPullParams($group->getParams()));
44 }
45
46 return $pullByUsers;
47 }
48
49 final public function getMobilePushByUsers(): array
50 {
51 if (!$this->shouldSendMobilePush())
52 {
53 return [];
54 }
55
56 return []; // TODO: Implement getMobilePushByUsers() method.
57 }
58
62 private function getPullParamsByUsers(): array
63 {
64 $recipients = $this->getRecipients();
65 $basePull = $this->getBasePullParams();
66 $skippedUserIds = $this->getSkippedUserIds();
67 if (!empty($skippedUserIds))
68 {
69 $recipients = array_diff($recipients, $skippedUserIds);
70 }
71
72 $pullParamsByUsers = [];
73 foreach ($recipients as $userId)
74 {
75 $diff = $this->getDiffByUser($userId);
76 $key = $diff->getKey();
77 $pullParamsByUsers[$key] ??= new Group(params: array_merge($basePull, $diff->params));
78 $pullParamsByUsers[$key]->addUser($userId);
79 }
80
81 return $pullParamsByUsers;
82 }
83
87 abstract protected function getRecipients(): array;
88
89 protected function getDiffByUser(int $userId): Diff
90 {
91 return new Diff($userId);
92 }
93
94 final protected function getBasePullParams(): array
95 {
96 $this->basePullParams ??= $this->getBasePullParamsInternal();
97
99 }
100
101 abstract protected function getBasePullParamsInternal(): array;
102
103 abstract protected function getType(): EventType;
104
105 private function wrapPullParams(array $pullParams): array
106 {
107 $wrappingParameters = $this->getWrappingParameters();
108 $wrappingParameters['params'] = $pullParams;
109
110 return $wrappingParameters;
111 }
112
113 private function getWrappingParameters(): array
114 {
115 if (isset($this->wrappingParameters))
116 {
117 return $this->wrappingParameters;
118 }
119
120 $this->wrappingParameters = [
121 'module_id' => $this->moduleId,
122 'command' => $this->getType()->value,
124 ];
125
126 if (isset($this->expiry))
127 {
128 $this->wrappingParameters['expiry'] = $this->expiry;
129 }
130
131 $skippedUserIds = $this->getSkippedUserIds();
132 if (!empty($skippedUserIds))
133 {
134 $this->wrappingParameters['skip_users'] = $skippedUserIds;
135 }
136
137 return $this->wrappingParameters;
138 }
139
140 protected function getSkippedUserIds(): array
141 {
142 return [];
143 }
144
145 public function isGlobal(): bool
146 {
147 return false;
148 }
149
151 {
152 return false;
153 }
154
155 public function shouldSendMobilePush(): bool
156 {
157 return false;
158 }
159}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getPullExtra()
Определения common.php:127
getMobilePushByUsers()
Определения BaseEvent.php:49
string $moduleId
Определения BaseEvent.php:14
array $basePullParams
Определения BaseEvent.php:15
shouldSendMobilePush()
Определения BaseEvent.php:155
Sender $sender
Определения BaseEvent.php:13
getSkippedUserIds()
Определения BaseEvent.php:140
int $expiry
Определения BaseEvent.php:12
getBasePullParams()
Определения BaseEvent.php:94
getPullByUsers()
Определения BaseEvent.php:36
shouldSendToOnlySpecificRecipients()
Определения BaseEvent.php:150
getDiffByUser(int $userId)
Определения BaseEvent.php:89
Определения result.php:20
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения BaseEvent.php:3
EventType
Определения EventType.php:6
if(empty($signedUserToken)) $key
Определения quickway.php:257