yupe\components\ModuleManager::getModulesDisabled PHP Method

getModulesDisabled() public method

Подгружает и выдает список отключенных модулей
Since: 0.5
public getModulesDisabled ( array $enableModule = [] ) : array
$enableModule array - список активных модулей, по умолчанию array()
return array список отключенных модулей
    public function getModulesDisabled($enableModule = [])
    {
        if (($imports = Yii::app()->getCache()->get('pathForImports')) !== false) {
            Yii::app()->getModule('yupe')->setImport($imports);
        }
        try {
            if ($imports === false || ($modules = Yii::app()->getCache()->get('modulesDisabled')) == false) {
                $modConfigs = Yii::getPathOfAlias('application.config.modules');
                $modPath = Yii::getPathOfAlias('application.modules');
                $cacheFile = Yii::app()->configManager->cacheFileName;
                foreach (new GlobIterator($modConfigs . '/*.php') as $item) {
                    if (is_dir($modPath . '/' . $item->getBaseName('.php')) == false && $cacheFile != $item->getBaseName('.php')) {
                        Yii::app()->getCache()->flush();
                        unlink($modConfigs . '/' . $item->getBaseName());
                        throw new Exception(Yii::t('YupeModule.yupe', 'There is an error occurred when try get modules from the cache. It seems that module\'s folder was deleted. Module is {module}...', ['module' => $item->getBaseName()]));
                    }
                }
                $path = $this->getModulesConfigDefault();
                $enableModule = array_keys($enableModule);
                $modules = [];
                $imports = [];
                if ($handler = opendir($path)) {
                    while ($dir = readdir($handler)) {
                        if (!$this->isValidModule($dir)) {
                            continue;
                        }
                        if ($dir != '.' && $dir != '..' && !is_file($dir) && !isset($enableModule[$dir])) {
                            $modules[$dir] = $this->getCreateModule($dir);
                            $imports[] = Yii::app()->getCache()->get('tmpImports');
                        }
                    }
                    closedir($handler);
                }
                $chain = new CChainedCacheDependency();
                // Зависимость на тег:
                $chain->dependencies->add(new TagsCache('yupe', 'modulesDisabled', 'getModulesDisabled', 'installedModules', 'pathForImports'));
                // Зависимость на каталог 'application.config.modules':
                $chain->dependencies->add(new CDirectoryCacheDependency(Yii::getPathOfAlias('application.config.modules')));
                Yii::app()->getCache()->set('modulesDisabled', $modules, 0, $chain);
                Yii::app()->getCache()->set('pathForImports', $imports, 0, $chain);
            }
        } catch (Exception $e) {
            Yii::app()->getCache()->flush();
            Yii::app()->user->setFlash(YFlashMessages::ERROR_MESSAGE, $e->getMessage());
            Yii::log($e->__toString(), \CLogger::LEVEL_ERROR);
            return false;
        }
        return $modules;
    }