1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pushworker.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\Integration\Push;
4
5use Bitrix\Main;
6use Bitrix\Main\Engine\CurrentUser;
7use Bitrix\Main\Loader;
8use Bitrix\Pull;
9
10final class PushWorker
11{
12 private bool $canUse;
13 private static $setJob = false;
14 private static $queue = [];
15
16 public function __construct()
17 {
18 $this->canUse = Loader::includeModule('pull');
19 }
20
21 public function subscribe(int $userId, string $command): void
22 {
23 if ($this->canUse)
24 {
25 \CPullWatch::Add($userId, $command);
26 }
27 }
28
29 public function send(string $command, array $params, array $userIds = []): void
30 {
31 if (empty($userIds))
32 {
33 $userIds = [CurrentUser::get()?->getId() ?? 0];
34 }
35
36 if ($this->canUse)
37 {
39 $userIds,
40 [
41 'module_id' => 'bizproc',
42 'command' => $command,
43 'params' => $params,
44 ]
45 );
46 }
47 }
48
49 public function sendLast(string $tag, string $command, array $params, array $userIds = [])
50 {
51 if ($this->canUse)
52 {
53 self::$queue[$tag] = [$command, $params, $userIds];
54 $this->setBackgroundJob();
55 }
56 }
57
58 private function setBackgroundJob()
59 {
60 if (!self::$setJob)
61 {
62 Main\Application::getInstance()->addBackgroundJob(
63 \Closure::fromCallable([__CLASS__, 'doBackgroundJob']),
64 [],
65 Main\Application::JOB_PRIORITY_LOW - 10
66 );
67 self::$setJob = true;
68 }
69 }
70
71 private static function doBackgroundJob()
72 {
73 $push = new self();
74 foreach (self::$queue as [$command, $params, $userIds])
75 {
76 $push->send($command, $params, $userIds);
77 }
78 }
79}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
sendLast(string $tag, string $command, array $params, array $userIds=[])
Определения pushworker.php:49
subscribe(int $userId, string $command)
Определения pushworker.php:21
send(string $command, array $params, array $userIds=[])
Определения pushworker.php:29
static getInstance()
Определения application.php:98
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
Определения event.php:22
</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