Pass the entire page data to the ModulePage

As module wizards might require some configuration values aggregated by
the main application wizard we pass the entire page data to each wizard as
if the data were aggregated by a module wizard itself.

refs #7163
This commit is contained in:
Johannes Meyer 2014-10-27 14:07:21 +01:00
parent b5468a122d
commit 3206ded18c
2 changed files with 18 additions and 6 deletions

View File

@ -18,7 +18,7 @@ class ModulePage extends Form
protected $modules;
protected $modulePaths;
protected $pageData;
/**
* Initialize this page
@ -30,9 +30,9 @@ class ModulePage extends Form
$this->session = Session::getSession()->getNamespace(get_class($this));
}
public function setModulePaths(array $availableDirs)
public function setPageData(array $pageData)
{
$this->modulePaths = $availableDirs;
$this->pageData = $pageData;
}
public function handleRequest(Request $request = null)
@ -115,7 +115,9 @@ class ModulePage extends Form
}
$moduleManager = Icinga::app()->getModuleManager();
$moduleManager->detectInstalledModules($this->modulePaths);
$moduleManager->detectInstalledModules(
explode(':', $this->pageData['setup_general_config']['global_modulePath'])
);
foreach ($moduleManager->listInstalledModules() as $moduleName) {
$this->modules[] = $moduleManager->loadModule($moduleName)->getModule($moduleName);
}
@ -137,6 +139,17 @@ class ModulePage extends Form
}
}
$this->mergePageData($this->wizards);
return $this->wizards;
}
protected function mergePageData(array $wizards)
{
foreach ($wizards as $wizard) {
$wizardPageData = & $wizard->getPageData();
foreach ($this->pageData as $pageName => $pageData) {
$wizardPageData[$pageName] = $pageData;
}
}
}
}

View File

@ -140,8 +140,7 @@ class WebSetup extends Wizard implements SetupWizard
unset($pageData['setup_authentication_backend']);
}
} elseif ($page->getName() === 'setup_modules') {
$configData = $this->getPageData('setup_general_config');
$page->setModulePaths(explode(':', $configData['global_modulePath']));
$page->setPageData($this->getPageData());
$page->handleRequest($request);
} elseif ($page->getName() === 'setup_general_config' && $this->getDirection() === static::FORWARD) {
$configData = $this->getPageData($page->getName());