Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
error.php
1<?php
2
3namespace Bitrix\Bizproc;
4
6
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}
static fromCode(string $code, $customData=null)
Definition error.php:13
static getLocalizationIdMap()
Definition error.php:42
const MODULE_NOT_INSTALLED
Definition error.php:9
static getCodes()
Definition error.php:33
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29