1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
EventCategoryPullService.php
См. документацию.
1<?php
2
4
11
13{
14 private static ?self $instance;
15
16 public static function getInstance(): self
17 {
18 self::$instance ??= new self();
19
20 return self::$instance;
21 }
22
23 public function createEvent(EventCategory $eventCategory): void
24 {
25 $eventCommonParams = [
26 'module_id' => PushService::MODULE_ID,
27 'command' => PushCommandEnum::EVENT_CATEGORY_CREATED->name,
28 'params' => [
29 'id' => $eventCategory->getId(),
31 eventCategory: $eventCategory,
32 isMuted: !$eventCategory->getClosed(),
33 )->toArray(),
34 ],
35 ];
36
37 $this->sendEvent($eventCategory, $eventCommonParams);
38 }
39
40 public function updateEvent(EventCategory $eventCategory, array $fields = [], ?int $userId = null): void
41 {
42 $eventCommonParams = [
43 'module_id' => PushService::MODULE_ID,
44 'command' => PushCommandEnum::EVENT_CATEGORY_UPDATED->name,
45 'params' => [
46 'id' => $eventCategory->getId(),
48 eventCategory: $eventCategory,
49 )->toArray(),
50 ],
51 ];
52
53 $this->sendEvent($eventCategory, $eventCommonParams, $userId);
54 }
55
56 public function deleteEvent(EventCategory $eventCategory): void
57 {
58 $eventCommonParams = [
59 'module_id' => PushService::MODULE_ID,
61 'params' => [
62 'fields' => [
63 'id' => $eventCategory->getId(),
64 ],
65 ],
66 ];
67
68 $this->sendEvent($eventCategory, $eventCommonParams);
69 }
70
71 private function generateTagByCategoryId(int $eventCategoryId): string
72 {
73 return sprintf('%s_%d', PushTagEnum::EVENT_CATEGORY->name, $eventCategoryId);
74 }
75
76 public function addToWatch(int $userId, ?int $eventCategoryId = null): void
77 {
78 if (!Loader::includeModule('pull'))
79 {
80 return;
81 }
82
83 $tag = $eventCategoryId
84 ? $this->generateTagByCategoryId($eventCategoryId)
85 : PushTagEnum::EVENT_CATEGORY->name;
86
87 \CPullWatch::Add($userId, $tag);
88 }
89
90 private function sendEvent(EventCategory $eventCategory, array $params, ?int $userId = null): void
91 {
92 if (!Loader::includeModule('pull'))
93 {
94 return;
95 }
96
97 if ($userId !== null)
98 {
99 PushService::addEvent([$userId], $params);
100 }
101 else
102 {
103 $tag = $eventCategory->getClosed()
104 ? $this->generateTagByCategoryId($eventCategory->getId())
105 : PushTagEnum::EVENT_CATEGORY->name;
106 PushService::addEventByTag($tag, $params);
107 }
108 }
109
110 private function __construct()
111 {
112 }
113}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static prepareEventCategoryForUserResponse(EventCategory $eventCategory, int $userId=0, ?bool $isMuted=null,)
Определения EventCategoryResponseHelper.php:14
updateEvent(EventCategory $eventCategory, array $fields=[], ?int $userId=null)
Определения EventCategoryPullService.php:40
addToWatch(int $userId, ?int $eventCategoryId=null)
Определения EventCategoryPullService.php:76
Определения loader.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
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$fields
Определения yandex_run.php:501