Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
entityeditorconfigscope.php
1<?php
2namespace Bitrix\UI\Form;
3
6
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
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getCaption(string $scope, string $entityTypeId='', ?int $scopeId=null, ?string $moduleId=null)
static getCaptions(string $entityTypeId='', ?string $moduleId=null)