parent
6967fffb1f
commit
6dd49761ff
|
@ -221,6 +221,23 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
|
|||
return isset($this->items[$name]) ? $this->items[$name] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the currently active item or the first one if none is active
|
||||
*
|
||||
* @return NavigationItem
|
||||
*/
|
||||
public function getActiveItem()
|
||||
{
|
||||
$firstItem = reset($this->items);
|
||||
foreach ($this->items as $item) {
|
||||
if ($item->getActive()) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $firstItem->setActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return this navigation's items
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue