mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 08:44:10 +02:00
Navigation: Clear the parent name from a configured navigation item
refs #5600
This commit is contained in:
parent
29413360d9
commit
95a3f1c011
@ -300,12 +300,15 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
|
|||||||
{
|
{
|
||||||
$flattened = $topLevel = array();
|
$flattened = $topLevel = array();
|
||||||
foreach ($config as $sectionName => $sectionConfig) {
|
foreach ($config as $sectionName => $sectionConfig) {
|
||||||
if (! $sectionConfig->parent) {
|
$parentName = $sectionConfig->parent;
|
||||||
|
unset($sectionConfig->parent);
|
||||||
|
|
||||||
|
if (! $parentName) {
|
||||||
$topLevel[$sectionName] = $sectionConfig->toArray();
|
$topLevel[$sectionName] = $sectionConfig->toArray();
|
||||||
$flattened[$sectionName] = & $topLevel[$sectionName];
|
$flattened[$sectionName] = & $topLevel[$sectionName];
|
||||||
} elseif (isset($flattened[$sectionConfig->parent])) {
|
} elseif (isset($flattened[$parentName])) {
|
||||||
$flattened[$sectionConfig->parent]['children'][$sectionName] = $sectionConfig->toArray();
|
$flattened[$parentName]['children'][$sectionName] = $sectionConfig->toArray();
|
||||||
$flattened[$sectionName] = & $flattened[$sectionConfig->parent]['children'][$sectionName];
|
$flattened[$sectionName] = & $flattened[$parentName]['children'][$sectionName];
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
t(
|
t(
|
||||||
@ -313,7 +316,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
|
|||||||
. ' sure that the parent is defined prior to its child(s).'
|
. ' sure that the parent is defined prior to its child(s).'
|
||||||
),
|
),
|
||||||
$sectionName,
|
$sectionName,
|
||||||
$sectionConfig->parent
|
$parentName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user