Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
classconstant.php
1
<?php
8
namespace
Bitrix\Sender\Internals
;
9
10
use
Bitrix\Main\Localization\Loc
;
11
use
Bitrix\Sender\Integration
;
12
13
Loc::loadMessages
(__FILE__);
14
19
class
ClassConstant
20
{
27
public
static
function
getName
($id)
28
{
29
static
$integration = [];
30
$integration[static::class] ??=
null
;
31
32
if
($integration[static::class] ===
null
)
33
{
34
$integration[static::class] = Integration\EventHandler::onConstantList(get_called_class());
35
}
36
37
foreach
($integration[static::class] as $item)
38
{
39
if
($item[
'id'
] === $id)
40
{
41
return
$item[
'name'
];
42
}
43
}
44
45
return
static::getCode($id);
46
}
47
53
protected
static
function
getConstants
()
54
{
55
static
$constants = [];
56
$constants[static::class] ??=
null
;
57
58
if
($constants[static::class] ===
null
)
59
{
60
$class = new \ReflectionClass(get_called_class());
61
$list = $class->getConstants();
62
63
$integration = Integration\EventHandler::onConstantList(get_called_class());
64
foreach
($integration as $item)
65
{
66
$list[$item[
'code'
]] = $item[
'id'
];
67
}
68
69
$constants[static::class] = $list;
70
}
71
72
return
$constants[static::class];
73
}
74
80
public
static
function
getList
()
81
{
82
$result = array();
83
$constants = static::getConstants();
84
foreach
($constants as $code => $id)
85
{
86
$result[] = $id;
87
}
88
return
$result;
89
}
90
96
public
static
function
getCodes
()
97
{
98
$result = array();
99
$constants = static::getConstants();
100
foreach
($constants as $code => $id)
101
{
102
$result[] = $code;
103
}
104
return
$result;
105
}
106
112
public
static
function
getNamedList
()
113
{
114
$result = array();
115
$constants = static::getConstants();
116
foreach
($constants as $code => $id)
117
{
118
$result[$id] = static::getName($id);
119
}
120
return
$result;
121
}
122
128
public
static
function
getNamedCodes
()
129
{
130
$result = array();
131
$constants = static::getConstants();
132
foreach
($constants as $code => $id)
133
{
134
$result[$code] = static::getName($id);
135
}
136
return
$result;
137
}
138
145
public
static
function
getId
($code)
146
{
147
$constants = static::getConstants();
148
return
isset($constants[$code]) ? $constants[$code] :
null
;
149
}
150
157
public
static
function
getCode
($id)
158
{
159
$constants = static::getConstants();
160
foreach
($constants as $constantCode => $constantId)
161
{
162
if
($constantId != $id)
163
{
164
continue
;
165
}
166
167
return
$constantCode;
168
}
169
170
return
null
;
171
}
172
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Sender\Internals\ClassConstant
Definition
classconstant.php:20
Bitrix\Sender\Internals\ClassConstant\getCode
static getCode($id)
Definition
classconstant.php:157
Bitrix\Sender\Internals\ClassConstant\getConstants
static getConstants()
Definition
classconstant.php:53
Bitrix\Sender\Internals\ClassConstant\getName
static getName($id)
Definition
classconstant.php:27
Bitrix\Sender\Internals\ClassConstant\getCodes
static getCodes()
Definition
classconstant.php:96
Bitrix\Sender\Internals\ClassConstant\getNamedList
static getNamedList()
Definition
classconstant.php:112
Bitrix\Sender\Internals\ClassConstant\getList
static getList()
Definition
classconstant.php:80
Bitrix\Sender\Internals\ClassConstant\getId
static getId($code)
Definition
classconstant.php:145
Bitrix\Sender\Internals\ClassConstant\getNamedCodes
static getNamedCodes()
Definition
classconstant.php:128
Bitrix\Sender\Integration
Bitrix\Sender\Internals
modules
sender
lib
internals
classconstant.php
Создано системой
1.10.0