Skip to content

Commit

Permalink
NavigationItem: Improve merge "algorithm"
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Meyer committed Oct 1, 2015
1 parent d54e5f6 commit 0cc06d6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions library/Icinga/Web/Navigation/NavigationItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -596,22 +596,32 @@ public function merge(NavigationItem $item)
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);
}
Expand Down

0 comments on commit 0cc06d6

Please sign in to comment.