base/ModulesManager.php
public static function modulesNamesList($module = null, $onlyActivated = true, $forModmgr = false
      , $onlyUniModule = false, $onlyLoaded = false, $indent = '. ')
    {
        $list = [];
        if (empty($module)) {
            $module = Yii::$app;
        }

        $modmgr = static::instance();

        if (method_exists ($modmgr, 'registeredModuleName')) {
            $label = $modmgr::registeredModuleName($module->uniqueId);
        }
        if (empty($label) && $module instanceof UniModule) {
            $label = $module->inform('label');
        }
        if (empty($label)) {
                $label = Yii::t(self::$tc, 'Module') . ' ' . $module->uniqueId;
        }

        if ($module != Yii::$app) { // skip application itself
            if (!$onlyUniModule || $module instanceof UniModule) {
                $prefix = str_repeat($indent, count(explode('/', $module->uniqueId)));
                $muid = $module->uniqueId;
                if ($forModmgr) {
                    $muid = $modmgr::tonumberModuleUniqueId($muid);
                }
                $list[$muid] = $prefix . $label;
            }
        }

        $staticSubmodules = $module->modules;
        $dynSubmodules = $modmgr->getSubmodules($module, $onlyActivated);
        $module->modules = ArrayHelper::merge($dynSubmodules, $staticSubmodules);
        if (empty($module->modules)) {
            return $list;
        }

        // add submodules list
        foreach ($module->modules as $childId => $childModule) {
            if (!$onlyLoaded && is_array($childModule)) {
                $childModule = $module->getModule($childId);
                //$childModule = Yii::$app->getModule($module->uniqueId . '/' . $childId);
            }
            if ($childModule instanceof YiiBaseModule) {
                $list += static::modulesNamesList($childModule, $onlyActivated, $forModmgr, $onlyUniModule, $onlyLoaded, $indent);
            }
        }
        return $list;
    }
public static function modulesNamesList($module = null, $onlyActivated = true, $forModmgr = false
      , $onlyUniModule = false, $onlyLoaded = false, $indent = '. ')
    {
        $list = [];
        if (empty($module)) {
            $module = Yii::$app;
        }

        $modmgr = static::instance();

        if (method_exists ($modmgr, 'registeredModuleName')) {
            $label = $modmgr::registeredModuleName($module->uniqueId);
        }
        if (empty($label) && $module instanceof UniModule) {
            $label = $module->inform('label');
        }
        if (empty($label)) {
                $label = Yii::t(self::$tc, 'Module') . ' ' . $module->uniqueId;
        }

        if ($module != Yii::$app) { // skip application itself
            if (!$onlyUniModule || $module instanceof UniModule) {
                $prefix = str_repeat($indent, count(explode('/', $module->uniqueId)));
                $muid = $module->uniqueId;
                if ($forModmgr) {
                    $muid = $modmgr::tonumberModuleUniqueId($muid);
                }
                $list[$muid] = $prefix . $label;
            }
        }

        $staticSubmodules = $module->modules;
        $dynSubmodules = $modmgr->getSubmodules($module, $onlyActivated);
        $module->modules = ArrayHelper::merge($dynSubmodules, $staticSubmodules);
        if (empty($module->modules)) {
            return $list;
        }

        // add submodules list
        foreach ($module->modules as $childId => $childModule) {
            if (!$onlyLoaded && is_array($childModule)) {
                $childModule = $module->getModule($childId);
                //$childModule = Yii::$app->getModule($module->uniqueId . '/' . $childId);
            }
            if ($childModule instanceof YiiBaseModule) {
                $list += static::modulesNamesList($childModule, $onlyActivated, $forModmgr, $onlyUniModule, $onlyLoaded, $indent);
            }
        }
        return $list;
    }
public static function modulesNamesList ( $ module = null , $ onlyActivated = true , $ forModmgr = false , $ onlyUniModule = false , $ onlyLoaded = false , $ indent = '. ' ) { $ list = [ ] ; if ( empty ( $ module ) ) { $ module = Yii :: $ app ; } $ modmgr = static :: instance ( ) ; if ( method_exists ( $ modmgr , 'registeredModuleName' ) ) { $ label = $ modmgr :: registeredModuleName ( $ module -> uniqueId ) ; } if ( empty ( $ label ) && $ module instanceof UniModule ) { $ label = $ module -> inform ( 'label' ) ; } if ( empty ( $ label ) ) { $ label = Yii :: t ( self :: $ tc , 'Module' ) . ' ' . $ module -> uniqueId ; } if ( $ module != Yii :: $ app ) { // skip application itself if ( ! $ onlyUniModule || $ module instanceof UniModule ) { $ prefix = str_repeat ( $ indent , count ( explode ( '/' , $ module -> uniqueId ) ) ) ; $ muid = $ module -> uniqueId ; if ( $ forModmgr ) { $ muid = $ modmgr :: tonumberModuleUniqueId ( $ muid ) ; } $ list [ $ muid ] = $ prefix . $ label ; } } $ staticSubmodules = $ module -> modules ; $ dynSubmodules = $ modmgr -> getSubmodules ( $ module , $ onlyActivated ) ; $ module -> modules = ArrayHelper :: merge ( $ dynSubmodules , $ staticSubmodules ) ; if ( empty ( $ module -> modules ) ) { return $ list ; } // add submodules list foreach ( $ module -> modules as $ childId => $ childModule ) { if ( ! $ onlyLoaded && is_array ( $ childModule ) ) { $ childModule = $ module -> getModule ( $ childId ) ; //$childModule = Yii::$app->getModule($module->uniqueId . '/' . $childId); } if ( $ childModule instanceof YiiBaseModule ) { $ list += static :: modulesNamesList ( $ childModule , $ onlyActivated , $ forModmgr , $ onlyUniModule , $ onlyLoaded , $ indent ) ; } } return $ list ; }
Get modules list in format uniqueId => label.
Use for modules dropdown list.
@param yii\base\Module|empty $module "parent"(container) module
@param boolean $onlyActivated if true show only activated in Modules manager
@param boolean $forModmgr if true not expand to string moduleId-number from Modules manager
@param boolean $onlyUniModule if false show only UniModule modules
@param boolean $onlyLoaded if false show only loaded modules
@param string $indent
@return array of module's uniqueId => module's label
Get modules list in format uniqueId = > label . Use for modules dropdown list .