Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
MaskManifest.php
1<?php
3
7
8Loc::loadMessages(__FILE__);
9
11{
12 private const USER_MASKS_MANIFEST_CODE = 'ui_masks';
13 private const SYSTEM_MASKS_MANIFEST_CODE = 'ui_masks_system';
14
15 public const CODE = 'ui_masks';
16
17 private static $manifestList = [
18 self::USER_MASKS_MANIFEST_CODE,
19 self::SYSTEM_MASKS_MANIFEST_CODE
20 ];
21 private static $entityList = [
22 'UI_MASK' => 10000,
23 ];
24
28 public static function onRestApplicationConfigurationGetManifest(): array
29 {
30 return [[
31 'CODE' => static::USER_MASKS_MANIFEST_CODE,
32 'VERSION' => 1,
33 'ACTIVE' => 'Y',
34 'USES' => [
35 'ui_masks',
36 ],
37 'DISABLE_CLEAR_FULL' => 'N',
38 'DISABLE_NEED_START_BTN' => 'Y',
39 'SKIP_CLEARING' => 'Y',
40 'PLACEMENT' => [],
41 'TITLE' => Loc::getMessage('UI_REST_MAIN_TITLE_PAGE'),
42 'DESCRIPTION' => Loc::getMessage('UI_REST_MAIN_DESCRIPTION_PAGE'),
43 'IMPORT_TITLE_PAGE' => Loc::getMessage('UI_REST_IMPORT_TITLE_PAGE'),
44 'IMPORT_TITLE_BLOCK' => Loc::getMessage('UI_REST_IMPORT_TITLE_BLOCK'),
45 'IMPORT_DESCRIPTION_UPLOAD' => Loc::getMessage('UI_REST_IMPORT_ACTION_DESCRIPTION'),
46 'IMPORT_DESCRIPTION_START' => Loc::getMessage('UI_REST_IMPORT_DESCRIPTION_START'),
47 'EXPORT_TITLE_PAGE' => Loc::getMessage('UI_REST_EXPORT_TITLE_PAGE'),
48 'EXPORT_TITLE_BLOCK' => Loc::getMessage('UI_REST_EXPORT_TITLE_BLOCK'),
49 'EXPORT_ACTION_DESCRIPTION' => Loc::getMessage('UI_REST_EXPORT_ACTION_DESCRIPTION'),
50 'IMPORT_FINISH_DESCRIPTION' => Loc::getMessage('UI_REST_IMPORT_FINISH_DESCRIPTION'),
51 'IMPORT_INSTALL_FINISH_TEXT' => '',
52 'REST_IMPORT_AVAILABLE' => 'Y',
53 'ACCESS' => [
54 'MODULE_ID' => 'ui',
55 'CALLBACK' => [
56 static::class,
57 'onCheckAccess'
58 ]
59 ]
60 ]];
61 }
68 public static function onCheckAccess(string $type, array $manifest): array
69 {
70 return [
71 'result' => true
72 ];
73 }
74
78 public static function OnRestApplicationConfigurationGetManifestSetting(Event $event): ?array
79 {
80 $manifestCode = $event->getParameter('CODE');
81 if (!in_array($manifestCode, static::$manifestList))
82 {
83 return null;
84 }
85
86 $result = [
87 'SETTING' => $event->getParameter('SETTINGS'),
88 'NEXT' => false
89 ];
90
91 return $result;
92 }
93
97 public static function onRestApplicationConfigurationEntity(): array
98 {
99 return static::$entityList;
100 }
101
102 public static function OnRestApplicationConfigurationExport(Event $event)
103 {
104 //region Check manifests intersection
105 $manifest = $event->getParameter('MANIFEST');
106 $intersection = array_intersect($manifest['USES'], static::$manifestList);
107 if (!$intersection)
108 {
109 return null;
110 }
111 //endregion
112
113 $entityCode = $event->getParameter('CODE');
114 if ($entityCode === 'UI_MASK')
115 {
116 return MaskExport::fulfill($event);
117 }
118 return null;
119 }
120
121 public static function onRestApplicationConfigurationImport(Event $event): ?array
122 {
123 //region Check manifests intersection
124 $manifest = $event->getParameter('IMPORT_MANIFEST');
125 $intersection = array_intersect($manifest['USES'], static::$manifestList);
126 if (!$intersection)
127 {
128 return null;
129 }
130 //endregion
131 $entityCode = $event->getParameter('CODE');
132 // TODO: Remove 2 string
133 // $event->setParameter('APP_ID', 6);
134 // $event->setParameter('CONTEXT', 'app6');
135 if ($entityCode === 'UI_MASK')
136 {
137 if (preg_match('/app(\d+)/is', $event->getParameter('CONTEXT')))
138 {
139 return MaskImportApp::fulfill($event);
140 }
141 return MaskImportPersonal::fulfill($event);
142 }
143 return null;
144 }
145
146 public static function bind()
147 {
148 $eventManager = Main\EventManager::getInstance();
149 foreach ([
150 'onRestApplicationConfigurationGetManifest',
151 'onRestApplicationConfigurationGetManifestSetting',
152 'onRestApplicationConfigurationExport',
153 'onRestApplicationConfigurationEntity',
154 'onRestApplicationConfigurationImport',
155 ] as $eventCode)
156 {
157 $eventManager->registerEventHandler('rest', $eventCode, 'ui', static::class, $eventCode);
158 }
159 }
160}
getParameter($key)
Definition event.php:80
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static fulfill(Main\Event $event)
static fulfill(Main\Event $event)
static onCheckAccess(string $type, array $manifest)
static OnRestApplicationConfigurationGetManifestSetting(Event $event)
static onRestApplicationConfigurationImport(Event $event)
static OnRestApplicationConfigurationExport(Event $event)