1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
manifest.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Rest\Configuration;
4
5
use Bitrix\Main\Event;
6
use Bitrix\Main\EventManager;
7
use Bitrix\Main\Loader;
8
9
class
Manifest
10
{
11
public
const
ACCESS_TYPE_IMPORT
=
'import'
;
12
public
const
ACCESS_TYPE_EXPORT
=
'export'
;
13
public
const
ON_REST_APP_CONFIGURATION_GET_MANIFEST
=
'OnRestApplicationConfigurationGetManifest'
;
14
public
const
ON_REST_APP_CONFIGURATION_GET_MANIFEST_SETTING
=
'OnRestApplicationConfigurationGetManifestSetting'
;
15
public
const
PROPERTY_REST_IMPORT_AVAILABLE
=
'REST_IMPORT_AVAILABLE'
;
16
private
static
$manifestList = [];
17
18
public
static
function
getList
()
19
{
20
if
(empty(static::$manifestList))
21
{
22
$event
=
new
Event
(
'rest'
, static::ON_REST_APP_CONFIGURATION_GET_MANIFEST);
23
EventManager::getInstance()->send(
$event
);
24
foreach
(
$event
->getResults() as $eventResult)
25
{
26
$manifestList = $eventResult->getParameters();
27
if
(is_array($manifestList))
28
{
29
static::$manifestList = array_merge(static::$manifestList, $manifestList);
30
}
31
}
32
}
33
34
return
static::$manifestList;
35
}
36
37
public
static
function
callEventInit
(
$code
,
$params
= [])
38
{
39
$result
= [];
40
$manifest = static::get(
$code
);
41
42
if
($manifest !==
false
&& isset(
$params
[
'TYPE'
]) && isset(
$params
[
'CONTEXT_USER'
]))
43
{
44
$step = intval(
$params
[
'STEP'
]);
45
$setting =
new
Setting
(
$params
[
'CONTEXT_USER'
]);
46
if
($step === 0)
47
{
48
$setting->delete(
Setting::SETTING_MANIFEST
);
49
}
50
51
$event
=
new
Event
(
52
'rest'
,
53
static::ON_REST_APP_CONFIGURATION_GET_MANIFEST_SETTING,
54
[
55
'CODE'
=> $manifest[
'CODE'
],
56
'MANIFEST'
=> $manifest,
57
'TYPE'
=>
$params
[
'TYPE'
],
58
'CONTEXT'
=>
$params
[
'CONTEXT'
] ??
false
,
59
'CONTEXT_USER'
=>
$params
[
'CONTEXT_USER'
],
60
'STEP'
=> $step,
61
'NEXT'
=> isset(
$params
[
'NEXT'
]) ?
$params
[
'NEXT'
] :
null
,
62
'ITEM_CODE'
=>
$params
[
'ITEM_CODE'
] ? :
null
,
63
'ADDITIONAL_OPTION'
=> is_array(
$params
[
'ADDITIONAL_OPTION'
]) ?
$params
[
'ADDITIONAL_OPTION'
] : [],
64
'SETTING'
=> $setting->get(
Setting::SETTING_MANIFEST
),
65
'USER_ID'
=> $setting->get(
Setting::SETTING_USER_ID
) ?? 0,
66
]
67
);
68
EventManager::getInstance()->send(
$event
);
69
foreach
(
$event
->getResults() as $eventResult)
70
{
71
$parameters = $eventResult->getParameters();
72
if
(isset($parameters[
'SETTING'
]))
73
{
74
$setting->set(
Setting::SETTING_MANIFEST
, $parameters[
'SETTING'
]);
75
}
76
77
$result
[] = [
78
'NEXT'
=> isset($parameters[
'NEXT'
]) ? $parameters[
'NEXT'
] :
false
,
79
'ERROR_MESSAGES'
=> $parameters[
'ERROR_MESSAGES'
] ??
null
,
80
'ERROR_ACTION'
=> $parameters[
'ERROR_ACTION'
] ?? null
81
];
82
}
83
}
84
return
$result
;
85
}
86
87
public
static
function
get
(
$code
)
88
{
89
$result
=
null
;
90
if
(
$code
!=
''
)
91
{
92
$manifestList = static::getList();
93
$key
= array_search(
$code
, array_column($manifestList,
'CODE'
));
94
if
(
$key
!==
false
)
95
{
96
$result
= $manifestList[
$key
];
97
}
98
}
99
100
return
$result
;
101
}
102
111
public
static
function
checkAccess
(
string
$type
, $manifestCode =
''
):
array
112
{
113
$result
= [
114
'result'
=>
false
,
115
'message'
=>
''
,
116
];
117
118
if
(\CRestUtil::isAdmin())
119
{
120
$result
[
'result'
] =
true
;
121
}
122
elseif
(!empty($manifestCode))
123
{
124
$manifest = static::get($manifestCode);
125
try
126
{
127
if
(
128
!empty($manifest[
'ACCESS'
][
'MODULE_ID'
])
129
&& is_array($manifest[
'ACCESS'
][
'CALLBACK'
])
130
&& Loader::includeModule($manifest[
'ACCESS'
][
'MODULE_ID'
])
131
&& is_callable($manifest[
'ACCESS'
][
'CALLBACK'
])
132
)
133
{
134
$access
= call_user_func($manifest[
'ACCESS'
][
'CALLBACK'
],
$type
, $manifest);
135
$result
[
'result'
] =
$access
[
'result'
] ===
true
;
136
$result
[
'message'
] = (is_string(
$access
[
'message'
]) &&
$access
[
'message'
] !==
''
) ?
$access
[
'message'
] :
''
;
137
}
138
}
139
catch
(\
Exception
$exception)
140
{
141
}
142
}
143
144
return
$result
;
145
}
146
156
public
static
function
isEntityAvailable
(
string
$entityCode,
array
$option
, $uses = []): bool
157
{
158
$manifest = [];
159
if
(!empty(
$option
[
'IMPORT_MANIFEST'
][
'USES'
]))
160
{
161
$manifest =
$option
[
'IMPORT_MANIFEST'
];
162
}
163
elseif
(!empty(
$option
[
'MANIFEST'
][
'USES'
]))
164
{
165
$manifest =
$option
[
'MANIFEST'
];
166
}
167
168
if
(empty($manifest[
'USES'
]))
169
{
170
return
false
;
171
}
172
173
$access
= array_intersect($manifest[
'USES'
], $uses);
174
if
(!
$access
)
175
{
176
return
false
;
177
}
178
179
return
true
;
180
}
181
187
public
static
function
isRestImportAvailable
(
string
$entityCode): bool
188
{
189
$manifest = static::get($entityCode);
190
return
isset($manifest[static::PROPERTY_REST_IMPORT_AVAILABLE]) && $manifest[static::PROPERTY_REST_IMPORT_AVAILABLE] ===
'Y'
;
191
}
192
}
$type
$type
Определения
options.php:106
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Rest\Configuration\Manifest
Определения
manifest.php:10
Bitrix\Rest\Configuration\Manifest\callEventInit
static callEventInit($code, $params=[])
Определения
manifest.php:37
Bitrix\Rest\Configuration\Manifest\checkAccess
static checkAccess(string $type, $manifestCode='')
Определения
manifest.php:111
Bitrix\Rest\Configuration\Manifest\ACCESS_TYPE_EXPORT
const ACCESS_TYPE_EXPORT
Определения
manifest.php:12
Bitrix\Rest\Configuration\Manifest\isRestImportAvailable
static isRestImportAvailable(string $entityCode)
Определения
manifest.php:187
Bitrix\Rest\Configuration\Manifest\ON_REST_APP_CONFIGURATION_GET_MANIFEST
const ON_REST_APP_CONFIGURATION_GET_MANIFEST
Определения
manifest.php:13
Bitrix\Rest\Configuration\Manifest\isEntityAvailable
static isEntityAvailable(string $entityCode, array $option, $uses=[])
Определения
manifest.php:156
Bitrix\Rest\Configuration\Manifest\ON_REST_APP_CONFIGURATION_GET_MANIFEST_SETTING
const ON_REST_APP_CONFIGURATION_GET_MANIFEST_SETTING
Определения
manifest.php:14
Bitrix\Rest\Configuration\Manifest\PROPERTY_REST_IMPORT_AVAILABLE
const PROPERTY_REST_IMPORT_AVAILABLE
Определения
manifest.php:15
Bitrix\Rest\Configuration\Manifest\getList
static getList()
Определения
manifest.php:18
Bitrix\Rest\Configuration\Manifest\ACCESS_TYPE_IMPORT
const ACCESS_TYPE_IMPORT
Определения
manifest.php:11
Bitrix\Rest\Configuration\Setting
Определения
setting.php:12
Bitrix\Rest\Configuration\Setting\SETTING_USER_ID
const SETTING_USER_ID
Определения
setting.php:18
Bitrix\Rest\Configuration\Setting\SETTING_MANIFEST
const SETTING_MANIFEST
Определения
setting.php:14
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$code
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения
options.php:195
$access
if(!is_array($deviceNotifyCodes)) $access
Определения
options.php:174
Bitrix\Main\DI\Exception
Определения
circulardependencyexception.php:3
$event
$event
Определения
prolog_after.php:141
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$option
$option
Определения
options.php:1711
bitrix
modules
rest
lib
configuration
manifest.php
Создано системой
1.14.0