src/Franzose/ClosureTable/Extensions/Collection.php
protected function makeTree(array &$items)
    {
        $result = [];
        $tops = [];

        /**
         * @var Entity $item
         */
        foreach ($items as $item) {
            $result[$item->getKey()] = $item;
        }

        foreach ($items as $item) {
            $parentId = $item->{$item->getParentIdColumn()};

            if (array_key_exists($parentId, $result)) {
                $result[$parentId]->appendRelation($item->getChildrenRelationIndex(), $item);
            } else {
                $tops[] = $item;
            }
        }

        return $tops;
    }
protected function makeTree(array &$items)
    {
        $result = [];
        $tops = [];

        /**
         * @var Entity $item
         */
        foreach ($items as $item) {
            $result[$item->getKey()] = $item;
        }

        foreach ($items as $item) {
            $parentId = $item->{$item->getParentIdColumn()};

            if (array_key_exists($parentId, $result)) {
                $result[$parentId]->appendRelation($item->getChildrenRelationIndex(), $item);
            } else {
                $tops[] = $item;
            }
        }

        return $tops;
    }
protected function makeTree ( array & $ items ) { $ result = [ ] ; $ tops = [ ] ; /**
         * @var Entity $item
         */ foreach ( $ items as $ item ) { $ result [ $ item -> getKey ( ) ] = $ item ; } foreach ( $ items as $ item ) { $ parentId = $ item -> { $ item -> getParentIdColumn ( ) } ; if ( array_key_exists ( $ parentId , $ result ) ) { $ result [ $ parentId ] -> appendRelation ( $ item -> getChildrenRelationIndex ( ) , $ item ) ; } else { $ tops [ ] = $ item ; } } return $ tops ; }
Performs actual tree building.

@param array $items
@return array
Performs actual tree building .