src/PHPCRAPI/PHPCR/Node.php
public function getReducedTree()
    {
        $parseTree = function (Node $node, Node $target) use ( &$parseTree ) {
            if (substr($target->getPath(),0, strlen($node->getPath())) != $node->getPath()) {
                return array();
            }
            $tree = array();

            foreach ($node->getNodes() as $child) {
                $tree[] = array(
                    'name'          =>  $child->getName(),
                    'path'          =>  $child->getPath(),
                    'hasChildren'   =>  $child->hasNodes(),
                    'children'      =>  $parseTree($child, $target)
                );
            }

            return $tree;
        };

        $treeFactory = function($parent, $node) use ($parseTree) {
            return [ '/' => [
                'name'          =>  '/',
                'path'          =>  '/',
                'hasChildren'   =>  $parent->hasNodes(),
                'children'      =>  $parseTree($parent, $node)
            ]];
        };

        if ($this->getPath() == '/') {
            return $treeFactory($this, $this);
        }

        $parent = $this;
        do {
            $parent = $parent->getParent();
        } while ($parent->getPath() != '/');

        return $treeFactory($parent, $this);
    }
public function getReducedTree()
    {
        $parseTree = function (Node $node, Node $target) use ( &$parseTree ) {
            if (substr($target->getPath(),0, strlen($node->getPath())) != $node->getPath()) {
                return array();
            }
            $tree = array();

            foreach ($node->getNodes() as $child) {
                $tree[] = array(
                    'name'          =>  $child->getName(),
                    'path'          =>  $child->getPath(),
                    'hasChildren'   =>  $child->hasNodes(),
                    'children'      =>  $parseTree($child, $target)
                );
            }

            return $tree;
        };

        $treeFactory = function($parent, $node) use ($parseTree) {
            return [ '/' => [
                'name'          =>  '/',
                'path'          =>  '/',
                'hasChildren'   =>  $parent->hasNodes(),
                'children'      =>  $parseTree($parent, $node)
            ]];
        };

        if ($this->getPath() == '/') {
            return $treeFactory($this, $this);
        }

        $parent = $this;
        do {
            $parent = $parent->getParent();
        } while ($parent->getPath() != '/');

        return $treeFactory($parent, $this);
    }
public function getReducedTree ( ) { $ parseTree = function ( Node $ node , Node $ target ) use ( & $ parseTree ) { if ( substr ( $ target -> getPath ( ) , 0 , strlen ( $ node -> getPath ( ) ) ) != $ node -> getPath ( ) ) { return array ( ) ; } $ tree = array ( ) ; foreach ( $ node -> getNodes ( ) as $ child ) { $ tree [ ] = array ( 'name' => $ child -> getName ( ) , 'path' => $ child -> getPath ( ) , 'hasChildren' => $ child -> hasNodes ( ) , 'children' => $ parseTree ( $ child , $ target ) ) ; } return $ tree ; } ; $ treeFactory = function ( $ parent , $ node ) use ( $ parseTree ) { return [ '/' => [ 'name' => '/' , 'path' => '/' , 'hasChildren' => $ parent -> hasNodes ( ) , 'children' => $ parseTree ( $ parent , $ node ) ] ] ; } ; if ( $ this -> getPath ( ) == '/' ) { return $ treeFactory ( $ this , $ this ) ; } $ parent = $ this ; do { $ parent = $ parent -> getParent ( ) ; } while ( $ parent -> getPath ( ) != '/' ) ; return $ treeFactory ( $ parent , $ this ) ; }
Return a the minimum tree to display for a node

@return array The tree

@api
Return a the minimum tree to display for a node