public function add($parent_id, $node_id, $node)
    {
        //is it a root ?
        if (in_array($parent_id, $this->config['default_parent'])) {
            if (!$this->config['create_root']) {
                $this->tree[$node_id] = $node;
                $this->finder[$node_id] = &$this->tree[$node_id];

                return true;
            }

            $node[$this->config['parent']] = $this->config['default_root_id'];
            $parent_id = $this->config['default_root_id'];
        }

        //is it in the finder ?
        if (array_key_exists($parent_id, $this->finder)) {
            $this->finder[$parent_id][$this->config['childs']][$node_id] = $node;
            $this->finder[$node_id] = &$this->finder[$parent_id][$this->config['childs']][$node_id];

            return true;
        }

        //could'nt find anything
        return false;
    }
public function add($parent_id, $node_id, $node)
    {
        //is it a root ?
        if (in_array($parent_id, $this->config['default_parent'])) {
            if (!$this->config['create_root']) {
                $this->tree[$node_id] = $node;
                $this->finder[$node_id] = &$this->tree[$node_id];

                return true;
            }

            $node[$this->config['parent']] = $this->config['default_root_id'];
            $parent_id = $this->config['default_root_id'];
        }

        //is it in the finder ?
        if (array_key_exists($parent_id, $this->finder)) {
            $this->finder[$parent_id][$this->config['childs']][$node_id] = $node;
            $this->finder[$node_id] = &$this->finder[$parent_id][$this->config['childs']][$node_id];

            return true;
        }

        //could'nt find anything
        return false;
    }
public function add ( $ parent_id , $ node_id , $ node ) { //is it a root ? if ( in_array ( $ parent_id , $ this -> config [ 'default_parent' ] ) ) { if ( ! $ this -> config [ 'create_root' ] ) { $ this -> tree [ $ node_id ] = $ node ; $ this -> finder [ $ node_id ] = & $ this -> tree [ $ node_id ] ; return true ; } $ node [ $ this -> config [ 'parent' ] ] = $ this -> config [ 'default_root_id' ] ; $ parent_id = $ this -> config [ 'default_root_id' ] ; } //is it in the finder ? if ( array_key_exists ( $ parent_id , $ this -> finder ) ) { $ this -> finder [ $ parent_id ] [ $ this -> config [ 'childs' ] ] [ $ node_id ] = $ node ; $ this -> finder [ $ node_id ] = & $ this -> finder [ $ parent_id ] [ $ this -> config [ 'childs' ] ] [ $ node_id ] ; return true ; } //could'nt find anything return false ; }
Add a leaf on the tree.

@param  string $parent_id
@param  string $node_id
@param  array $node
@return bool
Add a leaf on the tree .