NavigationItem: Accept arrays for method setChildren()

refs #5600
This commit is contained in:
Johannes Meyer 2015-09-02 12:59:05 +02:00
parent 83974b7698
commit b3159ee60d
1 changed files with 8 additions and 2 deletions

View File

@ -269,12 +269,18 @@ class NavigationItem implements Countable, IteratorAggregate
/** /**
* Set children * Set children
* *
* @param Navigation $children * @param array|Navigation $children
* *
* @return $this * @return $this
*/ */
public function setChildren(Navigation $children) public function setChildren($children)
{ {
if (is_array($children)) {
$children = Navigation::fromArray($children);
} elseif (! $children instanceof Navigation) {
throw new InvalidArgumentException('Argument $children must be of type array or Navigation');
}
$this->children = $children; $this->children = $children;
return $this; return $this;
} }