Add Wizard::skipPage()
Required to not to duplicate code in custom wizards and to avoid errors when detecting the direction. refs #8191
This commit is contained in:
parent
573c1046bb
commit
1f6a81aefb
|
@ -440,6 +440,36 @@ class Wizard
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the next or previous page based on the given one
|
||||
*
|
||||
* @param Form $page The page to skip
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function skipPage(Form $page)
|
||||
{
|
||||
if ($this->parent) {
|
||||
return $this->parent->skipPage($page);
|
||||
}
|
||||
|
||||
if ($this->hasPageData($page->getName())) {
|
||||
$pageData = & $this->getPageData();
|
||||
unset($pageData[$page->getName()]);
|
||||
}
|
||||
|
||||
$pages = $this->getPages();
|
||||
if ($this->getDirection() === static::FORWARD) {
|
||||
$nextPage = $pages[array_search($page, $pages, true) + 1];
|
||||
$newPage = $this->getNewPage($nextPage->getName(), $page);
|
||||
} else { // $this->getDirection() === static::BACKWARD
|
||||
$previousPage = $pages[array_search($page, $pages, true) - 1];
|
||||
$newPage = $this->getNewPage($previousPage->getName(), $page);
|
||||
}
|
||||
|
||||
return $newPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given page is this wizard's last page
|
||||
*
|
||||
|
|
|
@ -79,23 +79,7 @@ class MonitoringWizard extends Wizard implements SetupWizard
|
|||
$skip = $backendData['type'] !== 'livestatus';
|
||||
}
|
||||
|
||||
if ($skip) {
|
||||
if ($this->hasPageData($newPage->getName())) {
|
||||
$pageData = & $this->getPageData();
|
||||
unset($pageData[$newPage->getName()]);
|
||||
}
|
||||
|
||||
$pages = $this->getPages();
|
||||
if ($this->getDirection() === static::FORWARD) {
|
||||
$nextPage = $pages[array_search($newPage, $pages, true) + 1];
|
||||
$newPage = $this->getNewPage($nextPage->getName(), $newPage);
|
||||
} else { // $this->getDirection() === static::BACKWARD
|
||||
$previousPage = $pages[array_search($newPage, $pages, true) - 1];
|
||||
$newPage = $this->getNewPage($previousPage->getName(), $newPage);
|
||||
}
|
||||
}
|
||||
|
||||
return $newPage;
|
||||
return $skip ? $this->skipPage($newPage) : $newPage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -218,23 +218,7 @@ class WebWizard extends Wizard implements SetupWizard
|
|||
}
|
||||
}
|
||||
|
||||
if ($skip) {
|
||||
if ($this->hasPageData($newPage->getName())) {
|
||||
$pageData = & $this->getPageData();
|
||||
unset($pageData[$newPage->getName()]);
|
||||
}
|
||||
|
||||
$pages = $this->getPages();
|
||||
if ($this->getDirection() === static::FORWARD) {
|
||||
$nextPage = $pages[array_search($newPage, $pages, true) + 1];
|
||||
$newPage = $this->getNewPage($nextPage->getName(), $newPage);
|
||||
} else { // $this->getDirection() === static::BACKWARD
|
||||
$previousPage = $pages[array_search($newPage, $pages, true) - 1];
|
||||
$newPage = $this->getNewPage($previousPage->getName(), $newPage);
|
||||
}
|
||||
}
|
||||
|
||||
return $newPage;
|
||||
return $skip ? $this->skipPage($newPage) : $newPage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue