interface FileResolutionStrategy (View source)

Represents a strategy for resolving files on a Flysystem Adapter.

Methods

public
resolveFileID(string $fileID, Filesystem $filesystem)

Try to resolve a file ID against the provided Filesystem.

public
softResolveFileID(string $fileID, Filesystem $filesystem)

Try to resolve a file ID against the provided Filesystem looking at newer versions of the file.

public
generateVariantFileID(ParsedFileID|array $tuple, Filesystem $filesystem)

Build a file ID for a variant so it follows the pattern of its original file. The variant may not exist on the Filesystem yet, but the original file has to. This is to make sure that variant files always follow the same pattern as the original file they are attached to.

public
searchForTuple(array|ParsedFileID $tuple, Filesystem $filesystem, bool $strict = true)

Try to find a file ID for an existing file using the provided file tuple.

public
string
buildFileID(array|ParsedFileID $tuple)

Build a file ID for the provided tuple, irrespective of its existence.

public
parseFileID($fileID)

Try to resolve the provided file ID string irrespective of whether it exists on the Filesystem or not.

public
generator|ParsedFileID[]|null
findVariants(array|ParsedFileID $tuple, Filesystem $filesystem)

Find all the variants of the provided tuple

public
string
cleanFilename(string $filename)

Normalise a filename to be consistent with this file resolution strategy.

public
stripVariant(string|ParsedFileID $fileID)

Given a fileID string or a Parsed File ID, create a matching ParsedFileID without any variant.

Details

ParsedFileID|null resolveFileID(string $fileID, Filesystem $filesystem)

Try to resolve a file ID against the provided Filesystem.

Parameters

string $fileID
Filesystem $filesystem

Return Value

ParsedFileID|null

Alternative FileID where the user should be redirected to.

ParsedFileID|null softResolveFileID(string $fileID, Filesystem $filesystem)

Try to resolve a file ID against the provided Filesystem looking at newer versions of the file.

Parameters

string $fileID
Filesystem $filesystem

Return Value

ParsedFileID|null

Alternative FileID where the user should be redirected to.

ParsedFileID generateVariantFileID(ParsedFileID|array $tuple, Filesystem $filesystem)

Build a file ID for a variant so it follows the pattern of its original file. The variant may not exist on the Filesystem yet, but the original file has to. This is to make sure that variant files always follow the same pattern as the original file they are attached to.

Parameters

ParsedFileID|array $tuple
Filesystem $filesystem

Return Value

ParsedFileID

ParsedFileID|null searchForTuple(array|ParsedFileID $tuple, Filesystem $filesystem, bool $strict = true)

Try to find a file ID for an existing file using the provided file tuple.

Parameters

array|ParsedFileID $tuple
Filesystem $filesystem
bool $strict

Whether we should enforce a hash check on the file we find

Return Value

ParsedFileID|null FileID

string buildFileID(array|ParsedFileID $tuple)

Build a file ID for the provided tuple, irrespective of its existence.

Should always return the preferred file ID for this resolution strategy.

Parameters

array|ParsedFileID $tuple

Return Value

string

ParsedFileID parseFileID($fileID)

Try to resolve the provided file ID string irrespective of whether it exists on the Filesystem or not.

Parameters

$fileID

Return Value

ParsedFileID

generator|ParsedFileID[]|null findVariants(array|ParsedFileID $tuple, Filesystem $filesystem)

Find all the variants of the provided tuple

Parameters

array|ParsedFileID $tuple
Filesystem $filesystem

Return Value

generator|ParsedFileID[]|null

Exceptions

FileNotFoundException

string cleanFilename(string $filename)

Normalise a filename to be consistent with this file resolution strategy.

Parameters

string $filename

Return Value

string

ParsedFileID|null stripVariant(string|ParsedFileID $fileID)

Given a fileID string or a Parsed File ID, create a matching ParsedFileID without any variant.

Parameters

string|ParsedFileID $fileID

Return Value

ParsedFileID|null

A ParsedFileID with the expected FileID of the original file or null if the provided $fileID could not be understood