Navigation: Add method hasRenderableItems()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-17 11:01:06 +02:00
parent bf4e492fa1
commit 4f5a5c83bc
3 changed files with 18 additions and 2 deletions

View File

@ -263,6 +263,22 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
return empty($this->items);
}
/**
* Return whether this navigation has any renderable items
*
* @return bool
*/
public function hasRenderableItems()
{
foreach ($this->getItems() as $item) {
if ($item->shouldRender()) {
return true;
}
}
return false;
}
/**
* Return this navigation's layout
*

View File

@ -27,7 +27,7 @@ if (isset($this->actions)) {
}
}
if ($navigation->isEmpty()) {
if ($navigation->isEmpty() || !$navigation->hasRenderableItems()) {
return;
}

View File

@ -32,7 +32,7 @@ if (! empty($links)) {
}
}
if ($navigation->isEmpty()) {
if ($navigation->isEmpty() || !$navigation->hasRenderableItems()) {
return;
}
?>