mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 23:34:08 +02:00
NavigationItem: Automatically determine whether it's active or not
refs #5600
This commit is contained in:
parent
baefc89f85
commit
07588595f2
@ -149,7 +149,21 @@ class NavigationItem implements IteratorAggregate
|
|||||||
*/
|
*/
|
||||||
public function getActive()
|
public function getActive()
|
||||||
{
|
{
|
||||||
return $this->active ?: false;
|
if ($this->active === null) {
|
||||||
|
$this->active = false;
|
||||||
|
if ($this->getUrl() !== null && Icinga::app()->getRequest()->getUrl()->matches($this->getUrl())) {
|
||||||
|
$this->setActive();
|
||||||
|
} elseif ($this->hasChildren()) {
|
||||||
|
foreach ($this->getChildren() as $item) {
|
||||||
|
/** @var NavigationItem $item */
|
||||||
|
if ($item->getActive()) {
|
||||||
|
// Do nothing, a true active state is automatically passed to all parents
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->active;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user