Navigation: Clear the parent name from a configured navigation item

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-02 15:14:55 +02:00
parent 29413360d9
commit 95a3f1c011
1 changed files with 8 additions and 5 deletions

View File

@ -300,12 +300,15 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
{
$flattened = $topLevel = array();
foreach ($config as $sectionName => $sectionConfig) {
if (! $sectionConfig->parent) {
$parentName = $sectionConfig->parent;
unset($sectionConfig->parent);
if (! $parentName) {
$topLevel[$sectionName] = $sectionConfig->toArray();
$flattened[$sectionName] = & $topLevel[$sectionName];
} elseif (isset($flattened[$sectionConfig->parent])) {
$flattened[$sectionConfig->parent]['children'][$sectionName] = $sectionConfig->toArray();
$flattened[$sectionName] = & $flattened[$sectionConfig->parent]['children'][$sectionName];
} elseif (isset($flattened[$parentName])) {
$flattened[$parentName]['children'][$sectionName] = $sectionConfig->toArray();
$flattened[$sectionName] = & $flattened[$parentName]['children'][$sectionName];
} else {
throw new ConfigurationError(
t(
@ -313,7 +316,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
. ' sure that the parent is defined prior to its child(s).'
),
$sectionName,
$sectionConfig->parent
$parentName
);
}
}