1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Error.php
См. документацию.
1
<?php
2
declare(strict_types=1);
3
4
namespace
Bitrix\Landing\Copilot\Generation
;
5
6
use
Bitrix\Landing\Copilot\Generation\Type\Errors
;
7
use
Bitrix\Main\Localization\Loc
;
8
9
class
Error
10
{
11
private
const
LANG_PREFIX =
'LANDING_AI_SITE_ERROR_'
;
12
private
const
DEFAULT_ERROR =
'LANDING_AI_SITE_ERROR'
;
13
14
public
string
$code
=
''
;
15
public
string
$message
=
''
;
16
17
public
function
getMessage
(): string
18
{
19
return
"{$this->code}: {$this->message}"
;
20
}
21
26
public
function
toArray
():
array
27
{
28
return
[
29
'code'
=>
$this->code
,
30
'message'
=>
$this->message
,
31
];
32
}
33
39
public
static
function
fromArray
(
array
$data
):
Error
40
{
41
$dto =
new
self
();
42
$dto->code =
$data
[
'code'
] ??
''
;
43
$dto->message =
$data
[
'message'
] ??
''
;
44
45
return
$dto;
46
}
47
53
public
static
function
createError
(?
Errors
$code
=
null
): self
54
{
55
$error
=
new
Error
();
56
57
if
(
$code
)
58
{
59
$error
->code =
$code
->name;
60
$error
->message = Loc::getMessage(self::LANG_PREFIX .
$code
->value) ??
''
;
61
}
62
else
63
{
64
$error
->code = self::DEFAULT_ERROR;
65
}
66
67
return
$error
;
68
}
69
}
Bitrix\Landing\Copilot\Generation\Error\fromArray
static fromArray(array $data)
Определения
Error.php:39
Bitrix\Landing\Copilot\Generation\Error\$code
string $code
Определения
Error.php:14
Bitrix\Landing\Copilot\Generation\Error\getMessage
getMessage()
Определения
Error.php:17
Bitrix\Landing\Copilot\Generation\Error\createError
static createError(?Errors $code=null)
Определения
Error.php:53
Bitrix\Landing\Copilot\Generation\Error\$message
string $message
Определения
Error.php:15
Bitrix\Landing\Copilot\Generation\Error\toArray
toArray()
Определения
Error.php:26
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Error\$code
$code
Определения
error.php:17
Bitrix\Main\Error\$message
$message
Определения
error.php:20
Bitrix\Main\Localization\Loc
Определения
loc.php:12
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Landing\Copilot\Generation\Type\Errors
Errors
Определения
Errors.php:7
Bitrix\Landing\Copilot\Generation
Определения
Error.php:4
$error
$error
Определения
subscription_card_product.php:20
bitrix
modules
landing
lib
Copilot
Generation
Error.php
Создано системой
1.14.0