为一个 Module 创建前端路由文件
@param $moduleName
500520
public static function addFrontEndRouteFile($moduleName)
    {
        $moduleName = camel_case($moduleName);
        $newRouteFilePath = dirname(config('scaffold.templates.frontend.routes')[1]) . DIRECTORY_SEPARATOR . $moduleName . '.js';
        if (!file_exists($newRouteFilePath)) {
            $src = self::template('frontend/routes.js');
            file_put_contents($newRouteFilePath, file_get_contents($src));
        }

        $routeLine = "...require('./$moduleName').default";
        $routesPath = config('scaffold.templates.frontend.routes')[1];
        if (str_contains(file_get_contents($routesPath), $routeLine) == false) {
            Utils::replaceFilePlaceholders($routesPath, [
                "default
  // Append More Routes. Don't remove me" =>
                    "default,\n  " . $routeLine . "\n  // Append More Routes. Don't remove me"
            ], null, null);
        }
    }
649596
public function setFileName($fileName)
	{
		$hasFilename = ($this->fileName !== null);
		
		if ($hasFilename) {
			$previousName = $this->fileName;
			$previousExtension = $this->getExtension();
		}
		
		parent::setFileName($fileName);
		
		if ($hasFilename) {
			
			$newExtension = $this->getExtension();

			if (strcasecmp($previousExtension, $newExtension) !== 0) {

				// restore name back to previous one. Because that's safer.
				parent::setFileName($previousName);

				throw new \RuntimeException('Extension change is not allowed');
			}
		}
	}
469237
protected function getCoreModulePath(string $moduleName, PathTransfer $pathTransfer): ?string
    {
        $path = $this->pathBuilder->getCoreModulePathByModuleName($moduleName, $pathTransfer);

        if (!file_exists($path)) {
            return null;
        }

        return $path;
    }
127261
public function addModule(string $moduleName)
    {
        $this->modules[$moduleName] = new \BFW\Module($moduleName);
        $this->modules[$moduleName]->loadModule();
    }
33449
protected function getCSVModuleAttr(string $moduleName) : array
    {
        if (empty($this->modules[$moduleName])) {
            return [];
        }

        return $this->modules[$moduleName];
    }
836821
public function add(Module $module)
    {
        $this->modules[$module->getName()] = $module;

        if ($module instanceof RootModule) {
            $this->rootModule = $module;
        }
    }
296413
public static function appendAlias(&$moduleName)
    {
        if (isset(self::$moduleAliases[$moduleName])) {
            $moduleName = self::$moduleAliases[$moduleName];
        }
    }
407535
public void addModuleToExport(final String moduleName) {

        if (m_modulesToExport == null) {
            m_modulesToExport = new HashSet<String>();
        }
        m_modulesToExport.add(moduleName);
    }
684655
protected function def($moduleName, $key = null, $isAddress = false, $default = null)
    {
        if($isAddress)
            $definition = json_decode($this->app['files']->get($moduleName.$this->configFile), true);
        else
            $definition = json_decode($this->app['files']->get($this->getModuleDirectory($moduleName).$this->configFile), true);

        if ($key)
            if (isset($definition[$key]))
                return $definition[$key];
            else
                return $default;
        else
            return $definition;
    }
505717
public function addModuleName($moduleName)
    {
        if (isset($this->moduleNames[$moduleName])) {
            throw new RuntimeException(sprintf(
                'The module "%s" was added to the graph twice.',
                $moduleName
            ));
        }

        $this->moduleNames[$moduleName] = true;
        $this->dependencies[$moduleName] = array();
    }
76081
public static function init($module = '')
    {
        // 定位模块目录
        $module = $module ? $module . DS : '';

        // 加载第三方拓展包
        require_once VENDOR_PATH . 'autoload' . EXT;

        // 加载助手函数
        include HOPE_PATH . 'helper' . EXT;

        // 初始化系统配置
        self::$config = Config::init();

        $path = APP_PATH . $module;

        // 加载公共文件
        if (is_file($path . 'common' . EXT)) {
            require $path . 'common' . EXT;
        }

        // 如果有自定义配置则加载
        if (is_file($path . 'config' . EXT)) {
            require $path . 'config' . EXT;
        }

    }
40494
protected function installModule(string $moduleName)
    {
        if (!isset($this->listToInstall[$moduleName])) {
            return;
        }
        
        $this->displayMsgNLInCli(' > Read for module '.$moduleName);
        
        $module         = $this->listToInstall[$moduleName];
        $installScripts = $module->getSourceInstallScript();
        
        if (empty($installScripts) || $installScripts === false) {
            $this->displayMsgNLInCli(' >> No script to run.');
            return;
        }
        
        if (!is_array($installScripts)) {
            $installScripts = [$installScripts];
        }
        
        foreach ($installScripts as $scriptPath) {
            $module->runInstallScript($scriptPath);
        }
    }
1049875
public function buildAssets($moduleName)
    {
        $module = $this->getModuleDirectory($moduleName);
        if ($module)
        {
            $module .= '/assets';
            if ($this->files->exists($module))
            {
                if (!@$this->files->copyDirectory($module, $this->getAssetDirectory($moduleName)))
                {
                    $this->errors->add('build_assets', 'Unable to build assets');
                    return false;
                }
            }
            return true;
        }
        return false;
    }
722170
protected function callModulesMethod($methodName)
    {
        $modules = Yii::$app->getModules();
        $returns = [];

        foreach ($modules as $moduleName => $module)
        {
            if (is_array($module)) {
                $module = Yii::$app->getModule($moduleName);
            }

            if (method_exists($module, $methodName)) {
                $returns[] = $module->$methodName();
            }
        }

        return $returns;
    }
1207130
public function getInstallInfo($moduleName)
    {
        if (!isset($this->installInfos[$moduleName])) {
            throw new NoSuchModuleException(sprintf(
                'Could not get install info: The module "%s" is not installed.',
                $moduleName
            ));
        }

        return $this->installInfos[$moduleName];
    }
711237
protected function registerModule($moduleName, \OtherCode\Rest\Modules\BaseModule $moduleInstance, $hook)
    {
        if (!in_array($hook, array_keys($this->modules))) {
            return false;
        }
        if (!array_key_exists($moduleName, $this->modules[$hook])) {
            $this->modules[$hook][$moduleName] = $moduleInstance;
            return true;
        }
        return false;
    }
395658
public function setModule($module) {
        if (empty($module)) {
            throw new \Exception("Module cannot be empty", 0, null); //todo: create error code
        } else if (!is_string($module)) {
            throw new \Exception("Module must be a string", 0, null); //todo: create error code
        } else {
            $this->module = $module;
        }
    }