Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
error.php
1
<?php
2
3
namespace
Bitrix\Bizproc
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
7
class
Error
extends
\Bitrix\Main\Error
8
{
9
public
const
MODULE_NOT_INSTALLED
=
'MODULE_NOT_INSTALLED'
;
10
public
const
USER_NOT_FOUND
=
'USER_NOT_FOUND'
;
11
public
const
FILE_NOT_FOUND
=
'FILE_NOT_FOUND'
;
12
13
public
static
function
fromCode
(
string
$code
,
$customData
=
null
): self
14
{
15
$locals = static::getLocalizationIdMap();
16
17
$replacement = [];
18
if
(
$code
=== static::MODULE_NOT_INSTALLED && is_array(
$customData
) && isset(
$customData
[
'moduleName'
]))
19
{
20
$replacement = [
'#MODULE_NAME#'
=>
$customData
[
'moduleName'
]];
21
}
22
23
if
(isset($locals[
$code
]))
24
{
25
return
new
static
(
Loc::getMessage
($locals[
$code
], $replacement),
$code
,
$customData
);
26
}
27
else
28
{
29
return
new
static
(
''
,
$code
,
$customData
);
30
}
31
}
32
33
public
static
function
getCodes
(): array
34
{
35
return
[
36
static::MODULE_NOT_INSTALLED,
37
static::USER_NOT_FOUND,
38
static::FILE_NOT_FOUND,
39
];
40
}
41
42
protected
static
function
getLocalizationIdMap
(): array
43
{
44
$map = [];
45
foreach
(static::getCodes() as
$code
)
46
{
47
$map[
$code
] =
'BIZPROC_ERROR_'
.
$code
;
48
}
49
50
return
$map;
51
}
52
}
Bitrix\Bizproc\Error
Definition
error.php:8
Bitrix\Bizproc\Error\fromCode
static fromCode(string $code, $customData=null)
Definition
error.php:13
Bitrix\Bizproc\Error\getLocalizationIdMap
static getLocalizationIdMap()
Definition
error.php:42
Bitrix\Bizproc\Error\MODULE_NOT_INSTALLED
const MODULE_NOT_INSTALLED
Definition
error.php:9
Bitrix\Bizproc\Error\USER_NOT_FOUND
const USER_NOT_FOUND
Definition
error.php:10
Bitrix\Bizproc\Error\getCodes
static getCodes()
Definition
error.php:33
Bitrix\Bizproc\Error\FILE_NOT_FOUND
const FILE_NOT_FOUND
Definition
error.php:11
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Error\$code
$code
Definition
error.php:16
Bitrix\Main\Error\$customData
$customData
Definition
error.php:23
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Bizproc
modules
bizproc
lib
error.php
Создано системой
1.10.0