NavigationItem: Improve merge "algorithm"

This commit is contained in:
Johannes Meyer 2015-10-01 17:12:55 +02:00
parent d54e5f62e6
commit 0cc06d6af9
1 changed files with 17 additions and 7 deletions

View File

@ -596,22 +596,32 @@ class NavigationItem implements IteratorAggregate
throw new ProgrammingError('Cannot merge, conflict detected.');
}
if ($this->priority === null && ($priority = $item->getPriority()) !== null) {
$this->setPriority($priority);
}
if ($item->getActive()) {
$this->setActive();
if ($this->priority === null) {
$priority = $item->getPriority();
if ($priority !== 100) {
$this->setPriority($priority);
}
}
if (! $this->getIcon()) {
$this->setIcon($item->getIcon());
}
if ($this->getLabel() === $this->getName()) {
if ($this->getLabel() === $this->getName() && $item->getLabel() !== $item->getName()) {
$this->setLabel($item->getLabel());
}
if ($this->target === null && ($target = $item->getTarget()) !== null) {
$this->setTarget($target);
}
if ($this->renderer === null) {
$renderer = $item->getRenderer();
if (get_class($renderer) !== 'NavigationItemRenderer') {
$this->setRenderer($renderer);
}
}
foreach ($item->getAttributes() as $name => $value) {
$this->setAttribute($name, $value);
}