Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Initiator.php
1
<?php
2
3
namespace
Bitrix\MessageService\Providers\Base
;
4
5
abstract
class
Initiator
implements
\Bitrix\MessageService\Providers\Initiator
6
{
7
public
function
getDefaultFrom
(): ?string
8
{
9
$fromList = $this->
getFromList
();
10
$from = isset($fromList[0]) ? $fromList[0][
'id'
] :
null
;
11
//Try to find alphanumeric from
12
foreach
($fromList as $item)
13
{
14
if
(!preg_match(
'#^[0-9]+$#'
, $item[
'id'
]))
15
{
16
$from = $item[
'id'
];
17
break
;
18
}
19
}
20
return
$from;
21
}
22
23
public
function
getFirstFromList
()
24
{
25
$fromList = $this->
getFromList
();
26
if
(!is_array($fromList))
27
{
28
return
null
;
29
}
30
31
foreach
($fromList as $item)
32
{
33
if
(isset($item[
'id'
]) && $item[
'id'
])
34
{
35
return
$item[
'id'
];
36
}
37
}
38
39
return
null
;
40
}
41
42
public
function
isCorrectFrom
($from): bool
43
{
44
$fromList = $this->
getFromList
();
45
foreach
($fromList as $item)
46
{
47
if
($from === $item[
'id'
])
48
{
49
return
true
;
50
}
51
}
52
return
false
;
53
}
54
}
Bitrix\MessageService\Providers\Base\Initiator
Definition
Initiator.php:6
Bitrix\MessageService\Providers\Base\Initiator\getDefaultFrom
getDefaultFrom()
Definition
Initiator.php:7
Bitrix\MessageService\Providers\Base\Initiator\getFirstFromList
getFirstFromList()
Definition
Initiator.php:23
Bitrix\MessageService\Providers\Base\Initiator\isCorrectFrom
isCorrectFrom($from)
Definition
Initiator.php:42
Bitrix\MessageService\Providers\Initiator
Definition
Initiator.php:6
Bitrix\MessageService\Providers\Initiator\getFromList
getFromList()
Bitrix\MessageService\Providers\Base
Definition
DemoManager.php:3
modules
messageservice
lib
Providers
Base
Initiator.php
Создано системой
1.10.0