Puli\Repository\JsonRepository::initWithDefaultOrder PHP Метод

initWithDefaultOrder() приватный Метод

This is necessary if we want to insert a non-default order entry for the first time.
private initWithDefaultOrder ( string $path, string $insertedPath, array $references )
$path string The path to initialize.
$insertedPath string The path that is being inserted.
$references array The references for each defined path mapping in the path chain.
    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);
        }
    }