private function initWithDefaultOrder($path, $insertedPath, $references)
    {
        $this->json['_order'][$path] = array();

        // Insert the default order, if none exists
        // i.e. long paths /a/b/c before short paths /a/b
        $parentPath = $path;

        while (true) {
            if (isset($references[$parentPath])) {
                $parentEntry = array(
                    'path' => $parentPath,
                    'references' => count($references[$parentPath]),
                );

                // Edge case: $parentPath equals $insertedPath. In this case we have
                // to subtract the entry that we're adding
                if ($parentPath === $insertedPath) {
                    --$parentEntry['references'];
                }

                if (0 !== $parentEntry['references']) {
                    $this->json['_order'][$path][] = $parentEntry;
                }
            }

            if ('/' === $parentPath) {
                break;
            }

            $parentPath = Path::getDirectory($parentPath);
        }
    }
private function initWithDefaultOrder($path, $insertedPath, $references)
    {
        $this->json['_order'][$path] = array();

        // Insert the default order, if none exists
        // i.e. long paths /a/b/c before short paths /a/b
        $parentPath = $path;

        while (true) {
            if (isset($references[$parentPath])) {
                $parentEntry = array(
                    'path' => $parentPath,
                    'references' => count($references[$parentPath]),
                );

                // Edge case: $parentPath equals $insertedPath. In this case we have
                // to subtract the entry that we're adding
                if ($parentPath === $insertedPath) {
                    --$parentEntry['references'];
                }

                if (0 !== $parentEntry['references']) {
                    $this->json['_order'][$path][] = $parentEntry;
                }
            }

            if ('/' === $parentPath) {
                break;
            }

            $parentPath = Path::getDirectory($parentPath);
        }
    }
private function initWithDefaultOrder ( $ path , $ insertedPath , $ references ) { $ this -> json [ '_order' ] [ $ path ] = array ( ) ; // Insert the default order, if none exists // i.e. long paths /a/b/c before short paths /a/b $ parentPath = $ path ; while ( true ) { if ( isset ( $ references [ $ parentPath ] ) ) { $ parentEntry = array ( 'path' => $ parentPath , 'references' => count ( $ references [ $ parentPath ] ) , ) ; // Edge case: $parentPath equals $insertedPath. In this case we have // to subtract the entry that we're adding if ( $ parentPath === $ insertedPath ) { -- $ parentEntry [ 'references' ] ; } if ( 0 !== $ parentEntry [ 'references' ] ) { $ this -> json [ '_order' ] [ $ path ] [ ] = $ parentEntry ; } } if ( '/' === $ parentPath ) { break ; } $ parentPath = Path :: getDirectory ( $ parentPath ) ; } }
Initializes the order of a path with the default order.

This is necessary if we want to insert a non-default order entry for
the first time.

@param string $path         The path to initialize.
@param string $insertedPath The path that is being inserted.
@param array  $references   The references for each defined path mapping
in the path chain.
Initializes the order of a path with the default order .