src/Titon/Db/Behavior/HierarchyBehavior.php
public function mapTree(array $nodes, array $mappedNodes = []) {
        if (!$mappedNodes) {
            return $nodes;
        }

        $tree = [];
        $pk = $this->getRepository()->getPrimaryKey();

        foreach ($nodes as $node) {
            $id = $node[$pk];

            if (isset($mappedNodes[$id])) {
                $node[$this->getConfig('treeField') ?: 'Nodes'] = $this->mapTree($mappedNodes[$id], $mappedNodes);
            }

            $tree[] = $node;
        }

        return $tree;
    }
public function mapTree(array $nodes, array $mappedNodes = []) {
        if (!$mappedNodes) {
            return $nodes;
        }

        $tree = [];
        $pk = $this->getRepository()->getPrimaryKey();

        foreach ($nodes as $node) {
            $id = $node[$pk];

            if (isset($mappedNodes[$id])) {
                $node[$this->getConfig('treeField') ?: 'Nodes'] = $this->mapTree($mappedNodes[$id], $mappedNodes);
            }

            $tree[] = $node;
        }

        return $tree;
    }
public function mapTree ( array $ nodes , array $ mappedNodes = [ ] ) { if ( ! $ mappedNodes ) { return $ nodes ; } $ tree = [ ] ; $ pk = $ this -> getRepository ( ) -> getPrimaryKey ( ) ; foreach ( $ nodes as $ node ) { $ id = $ node [ $ pk ] ; if ( isset ( $ mappedNodes [ $ id ] ) ) { $ node [ $ this -> getConfig ( 'treeField' ) ? : 'Nodes' ] = $ this -> mapTree ( $ mappedNodes [ $ id ] , $ mappedNodes ) ; } $ tree [ ] = $ node ; } return $ tree ; }
Map a nested tree of arrays using the parent node stack and the mapped nodes by parent ID.

@param array $nodes
@param array $mappedNodes
@return array
Map a nested tree of arrays using the parent node stack and the mapped nodes by parent ID .