src/Tree.php
protected function add($parentName = null, $nodeName, ChildNodeInterface $node, $prepend = false)
    {
        if (!self::addTreeNode($this->hierarchy, $parentName, $nodeName, $prepend)) {
            throw new NodeNotFoundException(
                "Can't add '$nodeName' node to '$parentName': '$parentName' node not found."
            );
        }
        $this->removeNodeFromList($nodeName);
        $this->nodes->set($nodeName, $node);
        $this->updateRequired = true;

        return $this;
    }
protected function add($parentName = null, $nodeName, ChildNodeInterface $node, $prepend = false)
    {
        if (!self::addTreeNode($this->hierarchy, $parentName, $nodeName, $prepend)) {
            throw new NodeNotFoundException(
                "Can't add '$nodeName' node to '$parentName': '$parentName' node not found."
            );
        }
        $this->removeNodeFromList($nodeName);
        $this->nodes->set($nodeName, $node);
        $this->updateRequired = true;

        return $this;
    }
protected function add ( $ parentName = null , $ nodeName , ChildNodeInterface $ node , $ prepend = false ) { if ( ! self :: addTreeNode ( $ this -> hierarchy , $ parentName , $ nodeName , $ prepend ) ) { throw new NodeNotFoundException ( "Can't add '$nodeName' node to '$parentName': '$parentName' node not found." ) ; } $ this -> removeNodeFromList ( $ nodeName ) ; $ this -> nodes -> set ( $ nodeName , $ node ) ; $ this -> updateRequired = true ; return $ this ; }
Adds new tree node. If node exists, replaces it.

@param string|null        $parentName root if null
@param string             $nodeName   new node name
@param ChildNodeInterface $node

@return $this
Adds new tree node . If node exists replaces it .