1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Error.php
См. документацию.
1<?php
2declare(strict_types=1);
3
5
8
9class 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}
static fromArray(array $data)
Определения Error.php:39
static createError(?Errors $code=null)
Определения Error.php:53
Определения error.php:15
$code
Определения error.php:17
$message
Определения error.php:20
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$error
Определения subscription_card_product.php:20