From c9050e2f21d38a0d028a8586dcdce6df70a2eaf3 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 Sep 2015 15:20:26 +0200 Subject: [PATCH] NavigationItem: Initialize $children before setting the properties refs #5600 --- .../Icinga/Web/Navigation/NavigationItem.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/library/Icinga/Web/Navigation/NavigationItem.php b/library/Icinga/Web/Navigation/NavigationItem.php index 925982bfd..95f7e982b 100644 --- a/library/Icinga/Web/Navigation/NavigationItem.php +++ b/library/Icinga/Web/Navigation/NavigationItem.php @@ -41,7 +41,7 @@ class NavigationItem implements Countable, IteratorAggregate protected $attributes = array(); /** - * Item's children + * This item's children * * @var Navigation */ @@ -105,16 +105,17 @@ class NavigationItem implements Countable, IteratorAggregate public function __construct($name, array $properties = null) { $this->setName($name); + $this->children = new Navigation(); + if (! empty($properties)) { $this->setProperties($properties); } - $this->children = new Navigation(); $this->init(); } /** - * Initialize the navigation item + * Initialize this NavigationItem */ public function init() { @@ -126,7 +127,7 @@ class NavigationItem implements Countable, IteratorAggregate */ public function count() { - return $this->children->count(); + return $this->getChildren()->count(); } /** @@ -134,7 +135,7 @@ class NavigationItem implements Countable, IteratorAggregate */ public function getIterator() { - return $this->children; + return $this->getChildren(); } /** @@ -253,13 +254,13 @@ class NavigationItem implements Countable, IteratorAggregate } /** - * Get whether the item has children + * Return whether this item has any children * - * @return bool + * @return bool */ public function hasChildren() { - return ! $this->children->isEmpty(); + return ! $this->getChildren()->isEmpty(); } /**