protected function buildTree($tree_data)
    {
        $parent_key = $this->config['parent'];
        $default_root_id = $this->config['default_root_id'];

        while (count($tree_data)) {
            $beginning_with = count($tree_data);

            foreach ($tree_data as $node_id => $node) {
                $node[$this->config['childs']] = [];
                $parent = (array_key_exists($parent_key, $node)) ? $node[$parent_key] : $default_root_id;
                if ($this->add($parent, $node[$this->config['id']], $node)) {
                    unset($tree_data[$node_id]);
                }
            }

            $this->ungracefulExit($beginning_with, $tree_data);
        }
    }
protected function buildTree($tree_data)
    {
        $parent_key = $this->config['parent'];
        $default_root_id = $this->config['default_root_id'];

        while (count($tree_data)) {
            $beginning_with = count($tree_data);

            foreach ($tree_data as $node_id => $node) {
                $node[$this->config['childs']] = [];
                $parent = (array_key_exists($parent_key, $node)) ? $node[$parent_key] : $default_root_id;
                if ($this->add($parent, $node[$this->config['id']], $node)) {
                    unset($tree_data[$node_id]);
                }
            }

            $this->ungracefulExit($beginning_with, $tree_data);
        }
    }
protected function buildTree ( $ tree_data ) { $ parent_key = $ this -> config [ 'parent' ] ; $ default_root_id = $ this -> config [ 'default_root_id' ] ; while ( count ( $ tree_data ) ) { $ beginning_with = count ( $ tree_data ) ; foreach ( $ tree_data as $ node_id => $ node ) { $ node [ $ this -> config [ 'childs' ] ] = [ ] ; $ parent = ( array_key_exists ( $ parent_key , $ node ) ) ? $ node [ $ parent_key ] : $ default_root_id ; if ( $ this -> add ( $ parent , $ node [ $ this -> config [ 'id' ] ] , $ node ) ) { unset ( $ tree_data [ $ node_id ] ) ; } } $ this -> ungracefulExit ( $ beginning_with , $ tree_data ) ; } }
Build the tree from the received data

@param array $tree_data The raw data to create a tree from
@throws \Exception
Build the tree from the received data