/** * @return moduleBase[] */ public function getModuleInstances() { $instances = []; foreach (systemStructure::getInstance()->getModules() as $moduleNamespace => $moduleName) { /** @var moduleBase $moduleClass */ $moduleClass = $moduleNamespace . '\\module'; $moduleInstance = $moduleClass::getInstance(); $instances[$moduleInstance->getModuleName()] = $moduleClass::getInstance(); } return $instances; }
/** * @return \mpcmf\modules\moduleBase\moduleBase[] */ public function getAllModules() { /** @var moduleBase[][] $sortedModules */ /** @var moduleBase[] $allModules */ static $sortedModules = [], $allModules; $appKey = get_called_class(); if (!isset($sortedModules[$appKey])) { if ($allModules === null) { $allModules = systemStructure::getInstance()->getModuleInstances(); } $sortedModules[$appKey] = $this->getModules(); foreach ($allModules as $moduleName => $moduleInstance) { if (!isset($sortedModules[$appKey][$moduleName])) { $sortedModules[$appKey][$moduleName] = $moduleInstance; } } } return $sortedModules[$appKey]; }