Puli\Repository\JsonRepository::appendPathAndFilterExisting PHP Method

appendPathAndFilterExisting() private method

This method takes all the given references, appends the nested path to each of them and then filters out the results that actually exist on the filesystem. Null references are filtered out. Link references should be followed with {@link followLinks()} before calling this method. The flag STOP_ON_FIRST may be used to stop the search at the first result.
private appendPathAndFilterExisting ( array $references, string $nestedPath, integer $flags ) : string[]
$references array The references.
$nestedPath string The nested path to append without leading slash ("/").
$flags integer A bitwise combination of the flag constants in this class.
return string[] The references with the nested path appended. Each reference is guaranteed to exist on the filesystem.
    private function appendPathAndFilterExisting(array $references, $nestedPath, $flags = 0)
    {
        $result = array();
        foreach ($references as $reference) {
            // Filter out null values
            // Links should be followed before calling this method
            if (null === $reference) {
                continue;
            }
            $nestedReference = rtrim($reference, '/') . '/' . $nestedPath;
            if (file_exists($nestedReference)) {
                $result[] = $nestedReference;
                if ($flags & self::STOP_ON_FIRST) {
                    return $result;
                }
            }
        }
        return $result;
    }