Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
basepush.php
1
<?php
2
3
namespace
Bitrix\Bizproc\Integration\Push
;
4
5
abstract
class
BasePush
6
{
7
public
const
EVENT_ADDED
=
'ADDED'
;
8
public
const
EVENT_UPDATED
=
'UPDATED'
;
9
public
const
EVENT_DELETED
=
'DELETED'
;
10
11
abstract
protected
static
function
getCommand
(): string;
12
13
public
static
function
subscribeUser
(
int
$userId): void
14
{
15
(
new
PushWorker
())->subscribe($userId, static::getCommand());
16
}
17
18
public
static
function
pushAdded
(mixed $itemId, ...$userIds): void
19
{
20
static::pushLastEvent(static::EVENT_ADDED, $itemId, $userIds);
21
}
22
23
public
static
function
pushUpdated
(mixed $itemId, ...$userIds): void
24
{
25
static::pushLastEvent(static::EVENT_UPDATED, $itemId, $userIds);
26
}
27
28
public
static
function
pushDeleted
(mixed $itemId, ...$userIds): void
29
{
30
static::pushLastEvent(static::EVENT_DELETED, $itemId, $userIds);
31
}
32
33
public
static
function
pushLastEvent
(
string
$eventName, mixed $itemId, array $userIds): void
34
{
35
$userIds = array_unique(\CBPHelper::flatten($userIds));
36
if
(empty($userIds))
37
{
38
return
;
39
}
40
41
$command = static::getCommand();
42
43
$push =
new
PushWorker
();
44
$push->sendLast(
45
"{$command}-{$itemId}-{$eventName}"
,
46
$command,
47
[
48
'eventName'
=> $eventName,
49
'items'
=> [
50
[
51
'id'
=> $itemId,
52
],
53
],
54
],
55
$userIds,
56
);
57
}
58
}
Bitrix\Bizproc\Integration\Push\BasePush
Definition
basepush.php:6
Bitrix\Bizproc\Integration\Push\BasePush\EVENT_UPDATED
const EVENT_UPDATED
Definition
basepush.php:8
Bitrix\Bizproc\Integration\Push\BasePush\getCommand
static getCommand()
Bitrix\Bizproc\Integration\Push\BasePush\pushDeleted
static pushDeleted(mixed $itemId,... $userIds)
Definition
basepush.php:28
Bitrix\Bizproc\Integration\Push\BasePush\EVENT_DELETED
const EVENT_DELETED
Definition
basepush.php:9
Bitrix\Bizproc\Integration\Push\BasePush\pushLastEvent
static pushLastEvent(string $eventName, mixed $itemId, array $userIds)
Definition
basepush.php:33
Bitrix\Bizproc\Integration\Push\BasePush\subscribeUser
static subscribeUser(int $userId)
Definition
basepush.php:13
Bitrix\Bizproc\Integration\Push\BasePush\EVENT_ADDED
const EVENT_ADDED
Definition
basepush.php:7
Bitrix\Bizproc\Integration\Push\BasePush\pushAdded
static pushAdded(mixed $itemId,... $userIds)
Definition
basepush.php:18
Bitrix\Bizproc\Integration\Push\BasePush\pushUpdated
static pushUpdated(mixed $itemId,... $userIds)
Definition
basepush.php:23
Bitrix\Bizproc\Integration\Push\PushWorker
Definition
pushworker.php:11
Bitrix\Bizproc\Integration\Push
Definition
basepush.php:3
modules
bizproc
lib
integration
push
basepush.php
Создано системой
1.10.0