Skip to content

Commit

Permalink
Pass the entire page data to the ModulePage
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Johannes Meyer committed Oct 29, 2014
1 parent b5468a1 commit 3206ded
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
21 changes: 17 additions & 4 deletions application/forms/Setup/ModulePage.php
Expand Up @@ -18,7 +18,7 @@ class ModulePage extends Form

protected $modules;

protected $modulePaths;
protected $pageData;

/**
* Initialize this page
Expand All @@ -30,9 +30,9 @@ public function init()
$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)
Expand Down Expand Up @@ -115,7 +115,9 @@ public function getModules()
}

$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);
}
Expand All @@ -137,6 +139,17 @@ public function getWizards()
}
}

$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;
}
}
}
}
3 changes: 1 addition & 2 deletions library/Icinga/Application/WebSetup.php
Expand Up @@ -140,8 +140,7 @@ public function setupPage(Form $page, Request $request)
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());
Expand Down

0 comments on commit 3206ded

Please sign in to comment.