获取模块信息.

@param string $module namespace of the module.

@return Module|null 未找到时返回Null
507737
public static function getModule($module) {
        $info = null;
        if (isset (self::$modules [ $module ])) {
            return self::$modules [ $module ];
        }

        return $info;
    }
1320949
protected function getExtendsClassName(string $module): string
    {
        $shortName = (new \ReflectionClass($module))->getShortName();
        $extendClassName = "Package{$shortName}";

        return $extendClassName;
    }
98437
public static function loadScriptingModule($module)
    {
        $fullScriptPath = false;

        //  Remove any quotes from this passed in module
        $module = trim(str_replace(["'", '"'], null, $module), ' /');

        //  Check the configured script paths
        if (null === ($script = array_get(static::$libraries, $module))) {
            $script = $module;
        }

        foreach (static::$libraryPaths as $key => $path) {
            $checkScriptPath = $path . DIRECTORY_SEPARATOR . $script;

            if (is_file($checkScriptPath) && is_readable($checkScriptPath)) {
                $fullScriptPath = $checkScriptPath;
                break;
            }
        }

        if (!$script || !$fullScriptPath) {
            throw new InternalServerErrorException(
                'The module "' . $module . '" could not be found in any known locations.'
            );
        }

        return file_get_contents($fullScriptPath);
    }
982959
public function getModuleNamespace()
    {
        if (!$this->module || '\\' == $this->module || '/' == $this->module) {
            return '\app';
        }
        if (isset($this->modules[$this->module]['namespace'])) {
            return $this->modules[$this->module]['namespace'];
        }
        return '\app\modules\\' . $this->module;
    }
1280322
final public function getFunctionName(\Twig_Node_Module $module)
    {
        if (null === $this->functionNamingStrategy) {
            $this->functionNamingStrategy = new DefaultFunctionNamingStrategy();
        }

        return $this->functionNamingStrategy->getFunctionName($module);
    }
1278041
public function module($module)
    {
        if (is_object($module)) {
            if (!($module instanceof ModuleInterface)) {
                $moduleType = get_class($module);

                throw new InvalidArgumentException("Given module object '$moduleType' does not implement 'Depend\\Abstraction\\ModuleInterface'");
            }

            $module->register($this);

            return $this;
        }

        if (!class_exists((string) $module)) {
            throw new InvalidArgumentException("Given class name '$module' could not be found");
        }

        return $this->module(new $module);
    }
259147
public function isModuleCurrent(string $module): bool
	{
		return strpos($this->getAction(true), $module) !== false;
	}
966001
public function canonical($module)
	{
		$module = preg_replace('/[^A-Z0-9_\.-]/i', '', $module);
		if (substr($module, 0, strlen('mod_')) != 'mod_')
		{
			$module = 'mod_' . $module;
		}
		return $module;
	}
504998
public function getModule($name)
	{
	    $name = $this->parseModuleAlias($name);
	    $uid = 'module.' . $name;
	    
	    if ($this->hasModule($name)) {
		    /* @var $module Module */
	        return $this->get($uid);
		} else {
		    $basePath = rtrim($this->basePath, '\\/' ) . '/' . $name;
		    if (file_exists($basePath)) {
		        
		        $this->setModule($name, $basePath);
		        
		        return $this->get($uid);;
		    }
		}
		
		return null;
	}
852676
protected function getModuleCommands($module)
    {
        $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/';

        $commands = [];
        foreach (array_keys($module->controllerMap) as $id) {
            $commands[] = $prefix . $id;
        }

        foreach ($module->getModules() as $id => $child) {
            if (($child = $module->getModule($id)) === null) {
                continue;
            }
            foreach ($this->getModuleCommands($child) as $command) {
                $commands[] = $command;
            }
        }

        $controllerPath = $module->getControllerPath();
        if (is_dir($controllerPath)) {
            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($controllerPath, \RecursiveDirectoryIterator::KEY_AS_PATHNAME));
            $iterator = new \RegexIterator($iterator, '/.*Controller\.php$/', \RecursiveRegexIterator::GET_MATCH);
            foreach ($iterator as $matches) {
                $file = $matches[0];
                $relativePath = str_replace($controllerPath, '', $file);
                $class = strtr($relativePath, [
                    '/' => '\\',
                    '.php' => '',
                ]);
                $controllerClass = $module->controllerNamespace . $class;
                if ($this->validateControllerClass($controllerClass)) {
                    $dir = ltrim(pathinfo($relativePath, PATHINFO_DIRNAME), '\\/');

                    $command = InflectorHelper::camel2id(substr(basename($file), 0, -14), '-', true);
                    if (!empty($dir)) {
                        $command = $dir . '/' . $command;
                    }
                    $commands[] = $prefix . $command;
                }
            }
        }

        return $commands;
    }
843501
public function getClassByModule($module): ?string
    {
        if ($module instanceof Module || $module instanceof ModuleModel) {
            return Module::findClass($module->type);
        }

        if (\is_string($module)) {
            return Module::findClass($module);
        }

        return null;
    }
1078013
public static function getModuleInstanceByName($name)
    {
        $instance = self::getInstance();
        foreach ($instance->getModules() as $module) {
            if ($module->title === $name) {
                return $module;
            }
        }
        return null;
    }
667648
public function setModule($module)
        {
            if (null !== $module && !is_string($module)) {
                throw new Exception(
                    'Invalid argument: $module must be a string or null'
                );
            }

            $this->_module    = $module;
            $this->_hrefCache = null;

            return $this;
        }
417721
private function loadBoot($module) {

		if(false === is_string($module)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($module)), E_USER_ERROR);
		}
		
		$boot = Path :: get('modules') . $module . DIRECTORY_SEPARATOR . Files :: get('boot');

		if(true === is_readable($boot)) {
			require_once($boot);
		}
	}
59219
public static function getLogger($module = "")
    {
        if (is_object($module))
            $module = get_class($module);
        elseif (empty($module) || strtoupper($module) === "ROOT")
            $module = "";
        $module = trim(str_replace('\\', '.', $module), ". \\");

        if (!isset(self::$module_loggers[$module]))
            self::$module_loggers[$module] = new Logger($module);

        return self::$module_loggers[$module];
    }
891733
protected function getThemePath($module=MODULE_NAME){
        // 获取当前主题名称
        $theme = $this->getTemplateTheme();
        // 获取当前主题的模版路径
        $tmplPath   =   C('VIEW_PATH'); // 模块设置独立的视图目录
        if(!$tmplPath){ 
            // 定义TMPL_PATH 则改变全局的视图目录到模块之外
            $tmplPath   =   defined('TMPL_PATH')? TMPL_PATH.$module.'/' : APP_PATH.$module.'/'.C('DEFAULT_V_LAYER').'/';
        }
        return $tmplPath.$theme;
    }
1098296
public function invokeModule($path, $module) {
        $module = $this->getRealModule($module);
        $module = new $module();
        if (!$module instanceof Module) {
            return $this->invokeClass($module, $path);
        }
        $module->boot();
        view()->setDirectory($module->getViewPath());
        // 允许模块内部进行自定义路由解析
        if (method_exists($module, 'invokeRoute')
            && ($response = $module->invokeRoute($path))) {
            return $response;
        }
        $baseName = $module->getControllerNamespace();
        return $this->invokePath($path, $baseName);
    }