NavigationConfigForm: Do not allow to delete parents

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-18 15:58:20 +02:00
parent 518cdad1a8
commit ed875b5297
1 changed files with 11 additions and 0 deletions

View File

@ -376,6 +376,8 @@ class NavigationConfigForm extends ConfigForm
* @param string $name
*
* @return $this
*
* @throws IcingaException In case the navigation item has still children
*/
public function delete($name)
{
@ -384,6 +386,15 @@ class NavigationConfigForm extends ConfigForm
throw new NotFoundError('No navigation item called "%s" found', $name);
}
$children = $this->getFlattenedChildren($name);
if (! empty($children)) {
throw new IcingaException(
'Unable to delete navigation item "%s". There are other items dependent from it: %s',
$name,
join(', ', $children)
);
}
$config->removeSection($name);
$this->setIniConfig($config);
return $this;