コード例 #1
0
ファイル: MenuItem.php プロジェクト: rasanga/KnpMenu
 public function addChild($child, array $options = array())
 {
     if (!$child instanceof ItemInterface) {
         $child = $this->factory->createItem($child, $options);
     } elseif (null !== $child->getParent()) {
         throw new \InvalidArgumentException('Cannot add menu item as child, it already belongs to another menu (e.g. has a parent).');
     }
     $child->setParent($this);
     $this->children[$child->getName()] = $child;
     return $child;
 }