Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
notify.php
1
<?php
2
namespace
Bitrix\Rest
;
3
4
use
Bitrix\Main\ArgumentException
;
5
use
Bitrix\Main\ArgumentNullException
;
6
7
class
Notify
8
{
9
const
NOTIFY_IM
=
'im'
;
10
const
NOTIFY_BOT
=
'bot'
;
11
12
protected
$type
;
13
protected
$userList
= array();
14
18
protected
$notifier
=
null
;
19
20
public
function
__construct
($notifyType, array
$userList
)
21
{
22
$this->
setType
($notifyType);
23
$this->
setUserList
($userList);
24
}
25
26
public
function
send
($clientId, $token, $method, $message)
27
{
28
foreach
($this->userList as $userId)
29
{
30
$this->
getNotifier
()->send($clientId, $userId, $token, $method, $message);
31
}
32
}
33
34
public
function
setType
($notifyType)
35
{
36
if
($notifyType == static::NOTIFY_IM || $notifyType == static::NOTIFY_BOT)
37
{
38
$this->type = $notifyType;
39
}
40
else
41
{
42
throw
new
ArgumentException
(
'Wrong notify type'
,
'type'
);
43
}
44
}
45
46
public
function
getType
()
47
{
48
return
$this->type
;
49
}
50
51
public
function
setUserList
(array
$userList
)
52
{
53
if
(count(
$userList
) > 0)
54
{
55
$this->userList =
$userList
;
56
}
57
else
58
{
59
throw
new
ArgumentNullException
(
'userList'
);
60
}
61
}
62
63
public
function
getUserList
()
64
{
65
return
$this->userList
;
66
}
67
71
protected
function
getNotifier
()
72
{
73
if
(!$this->notifier)
74
{
75
switch
($this->type)
76
{
77
case
static::NOTIFY_IM:
78
$this->notifier =
new
NotifyIm
();
79
break
;
80
case
static::NOTIFY_BOT:
81
$this->notifier =
new
NotifyIm
();
82
break
;
83
}
84
}
85
86
return
$this->notifier
;
87
}
88
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ArgumentNullException
Definition
exception.php:54
Bitrix\Rest\Notify
Definition
notify.php:8
Bitrix\Rest\Notify\__construct
__construct($notifyType, array $userList)
Definition
notify.php:20
Bitrix\Rest\Notify\setUserList
setUserList(array $userList)
Definition
notify.php:51
Bitrix\Rest\Notify\send
send($clientId, $token, $method, $message)
Definition
notify.php:26
Bitrix\Rest\Notify\NOTIFY_IM
const NOTIFY_IM
Definition
notify.php:9
Bitrix\Rest\Notify\$userList
$userList
Definition
notify.php:13
Bitrix\Rest\Notify\NOTIFY_BOT
const NOTIFY_BOT
Definition
notify.php:10
Bitrix\Rest\Notify\getType
getType()
Definition
notify.php:46
Bitrix\Rest\Notify\$type
$type
Definition
notify.php:12
Bitrix\Rest\Notify\setType
setType($notifyType)
Definition
notify.php:34
Bitrix\Rest\Notify\getNotifier
getNotifier()
Definition
notify.php:71
Bitrix\Rest\Notify\$notifier
$notifier
Definition
notify.php:18
Bitrix\Rest\Notify\getUserList
getUserList()
Definition
notify.php:63
Bitrix\Rest\NotifyIm
Definition
notifyim.php:12
Bitrix\Rest
Definition
accessexception.php:2
modules
rest
lib
notify.php
Создано системой
1.10.0