20 if (empty(static::$manifestList))
22 $event =
new Event(
'rest', static::ON_REST_APP_CONFIGURATION_GET_MANIFEST);
23 EventManager::getInstance()->send($event);
24 foreach ($event->getResults() as $eventResult)
26 $manifestList = $eventResult->getParameters();
27 if (is_array($manifestList))
29 static::$manifestList = array_merge(static::$manifestList, $manifestList);
34 return static::$manifestList;
40 $manifest = static::get($code);
42 if ($manifest !==
false && isset($params[
'TYPE']) && isset($params[
'CONTEXT_USER']))
44 $step = intval($params[
'STEP']);
45 $setting =
new Setting($params[
'CONTEXT_USER']);
53 static::ON_REST_APP_CONFIGURATION_GET_MANIFEST_SETTING,
55 'CODE' => $manifest[
'CODE'],
56 'MANIFEST' => $manifest,
57 'TYPE' => $params[
'TYPE'],
58 'CONTEXT' => $params[
'CONTEXT'] ??
false,
59 'CONTEXT_USER' => $params[
'CONTEXT_USER'],
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'] : [],
68 EventManager::getInstance()->
send($event);
69 foreach ($event->getResults() as $eventResult)
71 $parameters = $eventResult->getParameters();
72 if (isset($parameters[
'SETTING']))
78 'NEXT' => isset($parameters[
'NEXT']) ? $parameters[
'NEXT'] :
false,
79 'ERROR_MESSAGES' => $parameters[
'ERROR_MESSAGES'] ??
null,
80 'ERROR_ACTION' => $parameters[
'ERROR_ACTION'] ?? null
111 public static function checkAccess(
string $type, $manifestCode =
''): array
118 if (\CRestUtil::isAdmin())
120 $result[
'result'] =
true;
122 elseif (!empty($manifestCode))
124 $manifest = static::get($manifestCode);
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'])
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'] :
'';
139 catch (\Exception $exception)