Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
entityeditorconfigscope.php
1
<?php
2
namespace
Bitrix\UI\Form
;
3
4
use
Bitrix\Main\Localization\Loc
;
5
use
Bitrix\Ui\EntityForm\Scope
;
6
7
class
EntityEditorConfigScope
8
{
9
const
UNDEFINED
=
''
;
10
const
PERSONAL
=
'P'
;
11
const
COMMON
=
'C'
;
12
const
CUSTOM
=
'CUSTOM'
;
13
14
private
static
$captions = array();
15
16
public
static
function
isDefined
(
string
$scope): bool
17
{
18
return
(in_array($scope, [self::PERSONAL, self::COMMON, self::CUSTOM],
true
));
19
}
20
26
public
static
function
getCaptions
(
string
$entityTypeId =
''
, ?
string
$moduleId =
null
): array
27
{
28
if
(!self::$captions[LANGUAGE_ID])
29
{
30
Loc::loadMessages
(__FILE__);
31
32
self::$captions[LANGUAGE_ID] = array(
33
self::PERSONAL =>
Loc::getMessage
(
'UI_ENTITY_ED_CONFIG_SCOPE_PERSONAL'
),
34
self::COMMON =>
Loc::getMessage
(
'UI_ENTITY_ED_CONFIG_SCOPE_COMMON'
)
35
);
36
37
if
($entityTypeId && $customScopes = Scope::getInstance()->getUserScopes($entityTypeId, $moduleId))
38
{
39
self::$captions[LANGUAGE_ID] = array_merge(
40
self::$captions[LANGUAGE_ID], [
'CUSTOM'
=> $customScopes]
41
);
42
}
43
}
44
45
return
self::$captions[LANGUAGE_ID];
46
}
47
55
public
static
function
getCaption
(
56
string
$scope,
57
string
$entityTypeId =
''
,
58
?
int
$scopeId =
null
,
59
?
string
$moduleId =
null
60
): string
61
{
62
$captions =
self::getCaptions
($entityTypeId, $moduleId);
63
if
($scope === self::CUSTOM && $entityTypeId && $scopeId)
64
{
65
return
$captions[$scope][$scopeId][
'NAME'
];
66
}
67
return
($captions[$scope] ??
"[{$scope}]"
);
68
}
69
}
70
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\UI\Form\EntityEditorConfigScope
Definition
entityeditorconfigscope.php:8
Bitrix\UI\Form\EntityEditorConfigScope\PERSONAL
const PERSONAL
Definition
entityeditorconfigscope.php:10
Bitrix\UI\Form\EntityEditorConfigScope\CUSTOM
const CUSTOM
Definition
entityeditorconfigscope.php:12
Bitrix\UI\Form\EntityEditorConfigScope\getCaption
static getCaption(string $scope, string $entityTypeId='', ?int $scopeId=null, ?string $moduleId=null)
Definition
entityeditorconfigscope.php:55
Bitrix\UI\Form\EntityEditorConfigScope\isDefined
static isDefined(string $scope)
Definition
entityeditorconfigscope.php:16
Bitrix\UI\Form\EntityEditorConfigScope\UNDEFINED
const UNDEFINED
Definition
entityeditorconfigscope.php:9
Bitrix\UI\Form\EntityEditorConfigScope\getCaptions
static getCaptions(string $entityTypeId='', ?string $moduleId=null)
Definition
entityeditorconfigscope.php:26
Bitrix\UI\Form\EntityEditorConfigScope\COMMON
const COMMON
Definition
entityeditorconfigscope.php:11
Bitrix\Ui\EntityForm\Scope
Definition
scope.php:23
Bitrix\UI\Form
Definition
entityeditorconfigscope.php:2
modules
ui
lib
form
entityeditorconfigscope.php
Создано системой
1.10.0