1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Push.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Link;
4
5
use Bitrix\Im\V2\Chat;
6
use Bitrix\Im\V2\Common\ContextCustomer;
7
use Bitrix\Im\V2\Rest\RestAdapter;
8
use Bitrix\Main\Application;
9
10
class
Push
11
{
12
use ContextCustomer;
13
14
protected
const
MODULE_ID
=
'im'
;
15
16
protected
array
$events
;
17
private
static
Push
$instance;
18
private
bool
$isJobPlanned =
false
;
19
20
private
function
__construct()
21
{
22
}
23
24
public
static
function
getInstance
(): self
25
{
26
if
(!isset(self::$instance))
27
{
28
self::$instance =
new
self
();
29
}
30
31
return
self::$instance;
32
}
33
34
public
function
sendFull
(
LinkRestConvertible
$link,
string
$eventName,
array
$endpoint): void
35
{
36
$this->
send
((
new
RestAdapter
($link))->toRestFormat(), $eventName, $endpoint);
37
}
38
39
public
function
sendIdOnly
(
LinkRestConvertible
$link,
string
$eventName,
array
$endpoint): void
40
{
41
$this->
send
($link->
toRestFormatIdOnly
(), $eventName, $endpoint);
42
}
43
44
protected
function
send
(
array
$params
,
string
$eventName,
array
$endpoint): void
45
{
46
$pull = [
47
'module_id'
=> self::MODULE_ID,
48
'command'
=> $eventName,
49
'params'
=>
$params
,
50
'extra'
=>
\Bitrix\Im\Common::getPullExtra
(),
51
];
52
$event
= [
'params'
=> $pull];
53
if
(isset($endpoint[
'CHAT_ID'
]))
54
{
55
$chat =
Chat::getInstance
((
int
)$endpoint[
'CHAT_ID'
]);
56
if
($chat->getType() === Chat::IM_TYPE_COMMENT)
57
{
58
$event
[
'tag'
] =
'IM_PUBLIC_COMMENT_'
. $chat->getParentChatId();
59
}
60
else
61
{
62
$event
[
'recipient'
] = $chat->getRelations()->getUserIds();
63
}
64
}
65
elseif
(isset($endpoint[
'RECIPIENT'
]))
66
{
67
$event
[
'recipient'
] = $endpoint[
'RECIPIENT'
];
68
}
69
else
70
{
71
return
;
72
}
73
74
$this->events[] =
$event
;
75
76
$this->
deferRun
();
77
}
78
79
protected
function
push
(): void
80
{
81
if
(!\
Bitrix
\
Main
\Loader::includeModule(
'pull'
))
82
{
83
return
;
84
}
85
foreach
($this->events as
$event
)
86
{
87
if
(isset(
$event
[
'recipient'
]))
88
{
89
\Bitrix\Pull\Event::add
(
$event
[
'recipient'
],
$event
[
'params'
]);
90
}
91
if
(isset(
$event
[
'tag'
]))
92
{
93
\CPullWatch::AddToStack(
$event
[
'tag'
],
$event
[
'params'
]);
94
}
95
}
96
$this->isJobPlanned =
false
;
97
$this->events = [];
98
}
99
100
protected
function
deferRun
(): void
101
{
102
if
(!$this->isJobPlanned)
103
{
104
Application::getInstance
()->addBackgroundJob(
function
() {
105
$this->
push
();
106
});
107
$this->isJobPlanned =
true
;
108
}
109
}
110
}
Bitrix\Im\Common\getPullExtra
static getPullExtra()
Определения
common.php:127
Bitrix\Im\V2\Link\Push
Определения
Push.php:11
Bitrix\Im\V2\Link\Push\sendFull
sendFull(LinkRestConvertible $link, string $eventName, array $endpoint)
Определения
Push.php:34
Bitrix\Im\V2\Link\Push\send
send(array $params, string $eventName, array $endpoint)
Определения
Push.php:44
Bitrix\Im\V2\Link\Push\MODULE_ID
const MODULE_ID
Определения
Push.php:14
Bitrix\Im\V2\Link\Push\$events
array $events
Определения
Push.php:16
Bitrix\Im\V2\Link\Push\deferRun
deferRun()
Определения
Push.php:100
Bitrix\Im\V2\Link\Push\sendIdOnly
sendIdOnly(LinkRestConvertible $link, string $eventName, array $endpoint)
Определения
Push.php:39
Bitrix\Im\V2\Link\Push\push
push()
Определения
Push.php:79
Bitrix\Im\V2\Link\Push\getInstance
static getInstance()
Определения
Push.php:24
Bitrix\Im\V2\Rest\RestAdapter
Определения
RestAdapter.php:10
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\DI\ServiceLocator\getInstance
static getInstance()
Определения
servicelocator.php:33
Bitrix\Pull\Event\add
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
Определения
event.php:22
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Im\V2\Link\LinkRestConvertible
Определения
LinkRestConvertible.php:10
Bitrix\Im\V2\Link\LinkRestConvertible\toRestFormatIdOnly
toRestFormatIdOnly()
Bitrix\Main
Bitrix
$event
$event
Определения
prolog_after.php:141
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
im
lib
V2
Link
Push.php
Создано системой
1.14.0