NavigationItem: Do not disable the complete parent hierarchy..

..if just a child gets deactivated.

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-02 15:32:37 +02:00
parent 2bfeb335a5
commit 6802c0a9e4
1 changed files with 10 additions and 10 deletions

View File

@ -27,11 +27,11 @@ class NavigationItem implements Countable, IteratorAggregate
const LINK_ALTERNATIVE = 'span'; const LINK_ALTERNATIVE = 'span';
/** /**
* Whether the item is active * Whether this item is active
* *
* @var bool * @var bool
*/ */
protected $active = false; protected $active;
/** /**
* The attributes of this item's element * The attributes of this item's element
@ -139,19 +139,19 @@ class NavigationItem implements Countable, IteratorAggregate
} }
/** /**
* Get whether the item is active * Return whether this item is active
* *
* @return bool * @return bool
*/ */
public function getActive() public function getActive()
{ {
return $this->active; return $this->active ?: false;
} }
/** /**
* Set whether the item is active * Set whether this item is active
* *
* Bubbles active state. * If it's active and has a parent, the parent gets activated as well.
* *
* @param bool $active * @param bool $active
* *
@ -160,10 +160,10 @@ class NavigationItem implements Countable, IteratorAggregate
public function setActive($active = true) public function setActive($active = true)
{ {
$this->active = (bool) $active; $this->active = (bool) $active;
$parent = $this; if ($this->active && $this->getParent() !== null) {
while (($parent = $parent->parent) !== null) { $this->getParent()->setActive();
$parent->setActive($active);
} }
return $this; return $this;
} }