From 997b57834cb188344515b3c14b0fb48737b3d845 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 Sep 2015 12:57:49 +0200 Subject: [PATCH] Navigation: Add method fromArray() refs #5600 --- library/Icinga/Web/Navigation/Navigation.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/library/Icinga/Web/Navigation/Navigation.php b/library/Icinga/Web/Navigation/Navigation.php index e4059629d..a7c1f46b3 100644 --- a/library/Icinga/Web/Navigation/Navigation.php +++ b/library/Icinga/Web/Navigation/Navigation.php @@ -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; + } }