NavigationItem: Set the parent on a child in method setChildren()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-02 15:21:40 +02:00
parent c9050e2f21
commit 5efcb18fa0
1 changed files with 7 additions and 3 deletions

View File

@ -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;
}