当前位置: 首页>>代码示例>>PHP>>正文


PHP ModuleManager::getInstalledModules方法代码示例

本文整理汇总了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;
 }
开发者ID:ASDAFF,项目名称:open_bx,代码行数:50,代码来源:loader.php

示例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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:61,代码来源:loader.php


注:本文中的ModuleManager::getInstalledModules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。