NavigationItem: Accept priority while merging if none is set yet

This commit is contained in:
Johannes Meyer 2015-10-01 16:32:47 +02:00
parent 57f30b1f92
commit d54e5f62e6
1 changed files with 5 additions and 2 deletions

View File

@ -131,7 +131,6 @@ class NavigationItem implements IteratorAggregate
public function __construct($name, array $properties = null) public function __construct($name, array $properties = null)
{ {
$this->setName($name); $this->setName($name);
$this->priority = 100;
$this->children = new Navigation(); $this->children = new Navigation();
if (! empty($properties)) { if (! empty($properties)) {
@ -207,7 +206,7 @@ class NavigationItem implements IteratorAggregate
*/ */
public function getPriority() public function getPriority()
{ {
return $this->priority; return $this->priority !== null ? $this->priority : 100;
} }
/** /**
@ -597,6 +596,10 @@ class NavigationItem implements IteratorAggregate
throw new ProgrammingError('Cannot merge, conflict detected.'); throw new ProgrammingError('Cannot merge, conflict detected.');
} }
if ($this->priority === null && ($priority = $item->getPriority()) !== null) {
$this->setPriority($priority);
}
if ($item->getActive()) { if ($item->getActive()) {
$this->setActive(); $this->setActive();
} }