components/TreeBuilder.php
public function generateTree($items, $relations)
    {
        $children = ArrayHelper::map($relations, 'child', 'parent');
        foreach ($relations as $relation) {
            if (!isset($items[$relation['child']]) || !isset($items[$relation['parent']])) {
                continue;
            }
            $tree = $items[$relation['parent']]['childrenTree'];
            $tree[] = &$items[$relation['child']];
            $items[$relation['parent']]['childrenTree'] = $tree;
        }

        return array_diff_key($items, $children);
    }
public function generateTree($items, $relations)
    {
        $children = ArrayHelper::map($relations, 'child', 'parent');
        foreach ($relations as $relation) {
            if (!isset($items[$relation['child']]) || !isset($items[$relation['parent']])) {
                continue;
            }
            $tree = $items[$relation['parent']]['childrenTree'];
            $tree[] = &$items[$relation['child']];
            $items[$relation['parent']]['childrenTree'] = $tree;
        }

        return array_diff_key($items, $children);
    }
public function generateTree ( $ items , $ relations ) { $ children = ArrayHelper :: map ( $ relations , 'child' , 'parent' ) ; foreach ( $ relations as $ relation ) { if ( ! isset ( $ items [ $ relation [ 'child' ] ] ) || ! isset ( $ items [ $ relation [ 'parent' ] ] ) ) { continue ; } $ tree = $ items [ $ relation [ 'parent' ] ] [ 'childrenTree' ] ; $ tree [ ] = & $ items [ $ relation [ 'child' ] ] ; $ items [ $ relation [ 'parent' ] ] [ 'childrenTree' ] = $ tree ; } return array_diff_key ( $ items , $ children ) ; }
Generates children tree.
@param $items
@param $relations
@return array $items children tree.
Generates children tree .