From 5efcb18fa0f548c015b430c5c8f490ee11d02d0f Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 2 Sep 2015 15:21:40 +0200 Subject: [PATCH] NavigationItem: Set the parent on a child in method setChildren() refs #5600 --- library/Icinga/Web/Navigation/NavigationItem.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Web/Navigation/NavigationItem.php b/library/Icinga/Web/Navigation/NavigationItem.php index 95f7e982b..a94b5fd8c 100644 --- a/library/Icinga/Web/Navigation/NavigationItem.php +++ b/library/Icinga/Web/Navigation/NavigationItem.php @@ -244,9 +244,9 @@ class NavigationItem implements Countable, IteratorAggregate } /** - * Get the item's children + * Return this item's children * - * @return Navigation + * @return Navigation */ public function getChildren() { @@ -264,7 +264,7 @@ class NavigationItem implements Countable, IteratorAggregate } /** - * Set children + * Set this item's children * * @param array|Navigation $children * @@ -278,6 +278,10 @@ class NavigationItem implements Countable, IteratorAggregate throw new InvalidArgumentException('Argument $children must be of type array or Navigation'); } + foreach ($children as $item) { + $item->setParent($this); + } + $this->children = $children; return $this; }