本文整理汇总了PHP中ModuleManager::getInstalledModules方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManager::getInstalledModules方法的具体用法?PHP ModuleManager::getInstalledModules怎么用?PHP ModuleManager::getInstalledModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleManager
的用法示例。
在下文中一共展示了ModuleManager::getInstalledModules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: includeModule
/**
* Includes module by its name
*
* @param string $moduleName Name of the included module
* @return bool Returns true if module was included successfully, otherwise returns false
* @throws LoaderException
*/
public static function includeModule($moduleName)
{
if (!is_string($moduleName) || $moduleName == "") {
throw new LoaderException("Empty module name");
}
if (preg_match("#[^a-zA-Z0-9._]#", $moduleName)) {
throw new LoaderException(sprintf("Module name '%s' is not correct", $moduleName));
}
$moduleName = strtr($moduleName, static::ALPHA_UPPER, static::ALPHA_LOWER);
if (self::SAFE_MODE) {
if (!in_array($moduleName, self::$safeModeModules)) {
return false;
}
}
if (isset(self::$arLoadedModules[$moduleName])) {
return self::$arLoadedModules[$moduleName];
}
if (isset(self::$arSemiloadedModules[$moduleName])) {
trigger_error("Module '" . $moduleName . "' is in loading progress", E_USER_WARNING);
}
$arInstalledModules = ModuleManager::getInstalledModules();
if (!isset($arInstalledModules[$moduleName])) {
return self::$arLoadedModules[$moduleName] = false;
}
$documentRoot = static::getDocumentRoot();
$moduleHolder = self::LOCAL_HOLDER;
$pathToInclude = $documentRoot . "/" . $moduleHolder . "/modules/" . $moduleName . "/include.php";
if (!file_exists($pathToInclude)) {
$moduleHolder = self::FREETRIX_HOLDER;
$pathToInclude = $documentRoot . "/" . $moduleHolder . "/modules/" . $moduleName . "/include.php";
if (!file_exists($pathToInclude)) {
return self::$arLoadedModules[$moduleName] = false;
}
}
self::$arLoadedModulesHolders[$moduleName] = $moduleHolder;
self::$arSemiloadedModules[$moduleName] = true;
$res = self::includeModuleInternal($pathToInclude);
unset(self::$arSemiloadedModules[$moduleName]);
if ($res === false) {
return self::$arLoadedModules[$moduleName] = false;
}
return self::$arLoadedModules[$moduleName] = true;
}
示例2: includeModule
public static function includeModule($moduleName)
{
if (!is_string($moduleName) || $moduleName == "") {
throw new LoaderException("Empty module name");
}
if (preg_match("#[^a-zA-Z0-9._]#", $moduleName)) {
throw new LoaderException(sprintf("Module name '%s' is not correct", $moduleName));
}
$moduleName = strtolower($moduleName);
if (self::SAFE_MODE) {
if (!in_array($moduleName, self::$safeModeModules)) {
return null;
}
}
if (array_key_exists($moduleName, self::$arLoadedModules)) {
return self::$arLoadedModules[$moduleName];
}
$arInstalledModules = ModuleManager::getInstalledModules();
if (!array_key_exists($moduleName, $arInstalledModules)) {
return self::$arLoadedModules[$moduleName] = null;
}
static $documentRoot = null;
if ($documentRoot === null) {
$documentRoot = Application::getDocumentRoot();
while (substr($documentRoot, -1) == "/") {
$documentRoot = substr($documentRoot, 0, -1);
}
}
$moduleHolder = self::LOCAL_HOLDER;
$pathToModule = $documentRoot . "/" . $moduleHolder . "/modules/" . $moduleName;
$pathToInclude = $pathToModule . "/include_module.php";
if (!file_exists($pathToInclude)) {
$pathToInclude = $pathToModule . "/include.php";
if (!file_exists($pathToInclude)) {
$moduleHolder = self::BITRIX_HOLDER;
$pathToModule = $documentRoot . "/" . $moduleHolder . "/modules/" . $moduleName;
$pathToInclude = $pathToModule . "/include_module.php";
if (!file_exists($pathToInclude)) {
$pathToInclude = $pathToModule . "/include.php";
if (!file_exists($pathToInclude)) {
return self::$arLoadedModules[$moduleName] = null;
}
}
}
}
$res = self::includeModuleInternal($pathToInclude);
if ($res === false) {
return self::$arLoadedModules[$moduleName] = null;
}
self::$arLoadedModulesHolders[$moduleName] = $moduleHolder;
if (strpos($moduleName, ".") !== false) {
$moduleNameTmp = str_replace(".", "_", $moduleName);
$className = "\\" . $moduleNameTmp . "\\" . $moduleNameTmp;
} else {
$className = "\\Bitrix\\" . $moduleName;
}
if (class_exists($className)) {
return self::$arLoadedModules[$moduleName] = new $className();
}
return self::$arLoadedModules[$moduleName] = true;
}