Adds a child to this node.

@param NodeInterface $child - Child.
@param bool $setChildParent - Set child's parent.

@throws ChildTypeNotSupportedException

@return NodeInterface
543983
public function addChild(NodeInterface $child, bool $setParent = true): NodeInterface
    {
        if (!$this->supportsChild($child)) {
            throw ChildTypeNotSupportedException::create($this, $child);
        }

        $this->_children[$child->getId()] = $child;

        if ($setParent) {
            $child->addParent($this, false);
        }

        /** @var NodeInterface $parent */
        foreach ($this->getAllParentsAndCurrentNode() as $parent) {
            $child->addSubscriber($parent);
        }

        $this->notifySubscribers(
            self::EVENT_ADD_CHILD,
            ['parent' => $this, 'child' => $child]
        );

        return $this;
    }
966922
public function appendChild(LeafInterface $child)
    {

        $this->prepareChild($child);
        $this->children[] = $child;
        $this->finishChild($child);

        return $this;
    }
1335131
public function addChild(FieldInterface $child)
    {
        $this->children->add($child);
        $child->setLayout($this);

        return $this;
    }
1351393
public function addChild(self $child)
    {
        if (isset($this->children[$child->name])) {
            throw new \InvalidArgumentException(sprintf(
                'Child with key "%s" already exists',
                $child->name
            ));
        }

        $this->children[$child->name] = $child;
    }
573732
public function moveAsFirstChildOf(NodeInterface $parentNode)
	{
		$this->validateAddingChildren($parentNode);
		
		$pos = $parentNode->getLeftValue() + 1;
		$level = $parentNode->getLevel() + 1;
		$this->move($pos, $level);

		return $this;
	}
927236
public function addChild(&$child)
	{
		JLog::add('JNode::addChild() is deprecated.', JLog::WARNING, 'deprecated');

		if ($child instanceof Jnode)
		{
			$child->setParent($this);
		}
	}
867299
public function addNestedSetChild(ChildCategory $category)
    {
        if (null === $this->collNestedSetChildren) {
            $this->initNestedSetChildren();
        }
        if (!in_array($category, $this->collNestedSetChildren->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
            $this->collNestedSetChildren[]= $category;
            $category->setParent($this);
        }
    }
225254
public function addChild(TreeNodeInterface $node)
    {
        $this->children[] = $node;
        $node->setParent($this);

        return $this;
    }
126987
public function removeChildNode(NodeInterface $childNode){
        $this->childNodes = array_filter($this->childNodes, function($node) use ($childNode){
            return $node !== $childNode;
        });
        return $this;
    }
18595
public void addChild(int offset, TreeElement child)
            throws IllegalArgumentException
    {
        child.setSelected(false);
        child.setParent(this);
        if (_children == null)
            _children = new ArrayList();
        _children.add(offset, child);

        //Need to rename all affected!
        int size = _children.size();
        for (int i = offset; i < size; i++) {
            TreeElement thisChild = (TreeElement) _children.get(i);
            thisChild.updateName(this, i);
        }

    }
140391
public function addChild($clientObject)
    {
        $this->data[] = $clientObject;
        if (is_null($clientObject->parentCollection))
            $clientObject->parentCollection = $this;
    }
709587
public function addChild(FieldGroupValueInterface $child)
    {
        $this->children->add($child);
        $child->setParent($this);

        return $this;
    }
1068454
public function setChildOf(Tree $parent)
    {
        if ($parent->type->name !== 'category') {
            throw new DomainException("Content can be assigned only to category parent");
        }
        return parent::setChildOf($parent);
    }
730766
public function addChild(Folder $child)
    {
        $this->children[] = $child;
        $child->setParent($this);

        return $this;
    }
1032757
public function addChild(Node $child)
    {
        $this->children[]            = $child;
        $child->parent               = $this;
        $child->properties['parent'] = $this->getId();
    }
653121
public function setParent(\Enhavo\Bundle\NavigationBundle\Model\NodeInterface $parent = null)
    {
        $this->parent = $parent;

        return $this;
    }
154887
public function setChild($parent, $child)
    {
        if (is_string($parent)) {
            $name   = $parent;
            $parent = $this->getItem($parent);
            if (is_null($parent)) {
                throw new Exception("Unknown parent:$name at setChild");
            }
        }
        if (is_string($child)) {
            $name  = $child;
            $child = $this->getItem($child);
            if (is_null($child)) {
                throw new Exception("Unknown child:$name at setChild");
            }
        }
        if (isset($this->children[$parent->name][$child->name])) {
            return false;
        }

        return $this->addChild($parent, $child);
    }