Puli\Repository\JsonRepository::resolveReferences PHP Method

resolveReferences() private method

Each reference passed in can be: * null * a link starting with @ * a filesystem path relative to the base directory * an absolute filesystem path Each reference returned by this method can be: * null * a link starting with @ * an absolute filesystem path Additionally, the results are guaranteed to be an array. The flag STOP_ON_FIRST may be used to stop the search at the first result. In that case, the results array has a maximum size of 1. The flag NO_SEARCH_FILESYSTEM may be used to check for whether the found paths actually exist on the filesystem.
private resolveReferences ( string $path, mixed $references, integer $flags ) : string[] | null[]
$path string The mapped Puli path.
$references mixed The reference(s).
$flags integer A bitwise combination of the flag constants in this class.
return string[] | null[] The resolved references.
    private function resolveReferences($path, $references, $flags = 0)
    {
        $result = array();
        if (!is_array($references)) {
            $references = array($references);
        }
        foreach ($references as $key => $reference) {
            // Keep non-filesystem references as they are
            if (!$this->isFilesystemReference($reference)) {
                $result[] = $reference;
                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }
                continue;
            }
            $absoluteReference = Path::makeAbsolute($reference, $this->baseDirectory);
            $referenceExists = file_exists($absoluteReference);
            if ($flags & self::NO_CHECK_FILE_EXISTS || $referenceExists) {
                $result[] = $absoluteReference;
                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }
            }
            if (!$referenceExists) {
                $this->logReferenceNotFound($path, $reference, $absoluteReference);
            }
        }
        return $result;
    }