Navigation: Add method fromArray()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-02 12:57:49 +02:00
parent 0788041c43
commit 997b57834c
1 changed files with 17 additions and 0 deletions

View File

@ -320,5 +320,22 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate
{
return new RecursiveNavigationRenderer($this);
}
/**
* Create and return a new set of navigation items for the given array
*
* @param array $array
*
* @return Navigation
*/
public static function fromArray(array $array)
{
$navigation = new static();
foreach ($array as $name => $properties) {
$navigation->addItem($name, $properties);
}
return $navigation;
}
}