21 private const CACHE_KEY =
'list';
22 private const METHOD_DELIMITER =
'.';
23 private const VENDOR_DELIMITER =
':';
26 private static $instance;
28 private $methodInfoList = [];
30 private function __construct()
40 if (self::$instance ===
null)
45 return self::$instance;
48 private function load() : bool
50 $this->scopeList = [];
51 $cache = Cache::createInstance();
52 if ($cache->initCache(self::CACHE_TIME, self::CACHE_KEY, self::CACHE_DIR))
54 $this->scopeList = $cache->getVars();
56 elseif ($cache->startDataCache())
60 foreach ($scopeList as
$code => $value)
66 foreach ($installedModuleList as
$moduleId => $moduleDescription)
72 if (!empty($controllersConfig[
'controllers'][
'restIntegration'][
'enabled']))
75 !isset($controllersConfig[
'controllers'][
'restIntegration'][
'hideModuleScope'])
76 || !$controllersConfig[
'controllers'][
'restIntegration'][
'hideModuleScope']
83 isset($controllersConfig[
'controllers'][
'restIntegration'][
'scopes'])
84 && is_array($controllersConfig[
'controllers'][
'restIntegration'][
'scopes'])
87 $this->scopeList = array_merge(
90 $controllersConfig[
'controllers'][
'restIntegration'][
'scopes'],
99 unset($this->scopeList[CRestUtil::GLOBAL_SCOPE]);
101 $cache->endDataCache($this->scopeList);
109 $this->methodInfoList = [];
122 return $this->scopeList[
$code] ??
null;
127 return array_keys($this->scopeList);
132 return array_unique(array_values($this->scopeList));
137 $langScope = Application::getDocumentRoot() .
BX_ROOT .
'/modules/rest/scope.php';
138 Loc::loadMessages($langScope);
143 if (mb_strtoupper(
$key) ===
'LOG')
145 $name = Loc::getMessage(
'REST_SCOPE_LOG_MSGVER_1');
146 $description = Loc::getMessage(
'REST_SCOPE_LOG_DESCRIPTION_MSGVER_1');
150 $name = Loc::getMessage(
'REST_SCOPE_' .
$key);
166 if (!(isset($this->methodInfoList[
$method]) && $this->methodInfoList[
$method]))
171 $actionParts = explode(self::METHOD_DELIMITER,
$method);
173 foreach ($actionParts as $partScope)
175 $scopeFind .= ($scopeFind !==
'' ? self::METHOD_DELIMITER :
'') . $partScope;
176 $moduleFind = $this->
getAlias($scopeFind);
179 $module = $moduleFind;
184 if (!$scope || !$module)
186 $scope = array_shift($actionParts);
189 elseif ($module !== $scope)
198 mb_strpos(
$method, self::VENDOR_DELIMITER) ===
false
199 && mb_strpos($module, self::METHOD_DELIMITER) !==
false
202 $moduleParts = explode(self::METHOD_DELIMITER, $module);
203 array_pop($moduleParts);
204 $vendor = implode(self::METHOD_DELIMITER, $moduleParts);
206 $method = preg_replace(
'/^' . $vendor . self::METHOD_DELIMITER .
'/', $vendor . self::VENDOR_DELIMITER,
$method);
209 $this->methodInfoList[
$method] = [
210 'moduleId' => $module,
216 return $this->methodInfoList[
$method];
221 static::cleanCache();
static clearCache($moduleId)
static getInstalledModules()
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)