1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pushservice.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Integration\Pull;
4
5use Bitrix\Main;
6use Bitrix\Pull\Event;
7
13
15{
16 public const MODULE_NAME = 'socialnetwork';
17
18 private static $instance;
19 private static $isJobOn = false;
20
21 private $registry = [];
22
26 private function __construct()
27 {
28
29 }
30
34 public static function getInstance(): PushService
35 {
36 if (!self::$instance)
37 {
38 self::$instance = new self();
39 }
40
41 return self::$instance;
42 }
43
48 public static function addEvent($recipients, array $params): void
49 {
50 $parameters = [
51 'RECIPIENTS' => $recipients,
52 'PARAMS' => $params,
53 ];
54 self::getInstance()->registerEvent($parameters);
55 self::getInstance()->addBackgroundJob();
56 }
57
58 public static function addEventByTag(string $tag, array $params): void
59 {
60 $parameters = [
61 'TAG' => $tag,
62 'PARAMS' => $params,
63 ];
64 self::getInstance()->registerEvent($parameters);
65 self::getInstance()->addBackgroundJob();
66 }
67
71 public static function proceed(): void
72 {
73 if (!Main\Loader::includeModule('pull'))
74 {
75 return;
76 }
77
78 self::getInstance()->sendEvents();
79 }
80
81 private function addBackgroundJob(): void
82 {
83 if (!self::$isJobOn)
84 {
86 $application && $application->addBackgroundJob([__CLASS__, 'proceed'], [], 0);
87
88 self::$isJobOn = true;
89 }
90 }
91
95 private function registerEvent(array $parameters): void
96 {
97 $this->registry[] = [
98 'TAG' => $parameters['TAG'] ?? '',
99 'RECIPIENTS' => $parameters['RECIPIENTS'] ?? [],
100 'PARAMS' => $parameters['PARAMS'],
101 ];
102 }
103
104 private function sendEvents(): void
105 {
106 foreach ($this->registry as $event)
107 {
108 if (isset($event['TAG']) && $event['TAG'] !== '')
109 {
110 $eventName = $event['PARAMS']['eventName'] ?? null;
111 $userId = $event['PARAMS']['userId'] ?? null;
112 $isPullUnsubscribe = $eventName === PushCommand::PULL_UNSUBSCRIBE;
113
114 ($isPullUnsubscribe && $userId)
115 ? \CPullWatch::Delete($userId, $event['TAG'])
116 : \CPullWatch::AddToStack($event['TAG'], $event['PARAMS'])
117 ;
118 }
119 else
120 {
121 Event::add($event['RECIPIENTS'], $event['PARAMS']);
122 }
123 }
124 }
125}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getInstance()
Определения application.php:98
static addEvent($recipients, array $params)
Определения pushservice.php:48
static addEventByTag(string $tag, array $params)
Определения pushservice.php:58
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$application
Определения bitrix.php:23
$event
Определения prolog_after.php:141
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799