SilverStripe\Assets\Flysystem\FlysystemAssetStore
Asset store based on flysystem Filesystem as a backend
Synopsis
class FlysystemAssetStore
implements
AssetStore,AssetStoreRouter,Flushable
{
- // constants
- const GRANTS_SESSION = 'AssetStore_Grants';
- // members
- private Filesystem $publicFilesystem = NULL;
- private Filesystem $protectedFilesystem = NULL;
- private FileResolutionStrategy $publicResolutionStrategy = NULL;
- private FileResolutionStrategy $protectedResolutionStrategy = NULL;
- private static bool $legacy_filenames = false;
- private static bool $keep_empty_dirs = false;
- private static integer $denied_response_code = 404;
- private static integer $missing_response_code = 404;
- private static integer $redirect_response_code = 302;
- private static integer $permanent_redirect_response_code = 301;
- private static array $file_response_headers = ;
- // methods
- public $this setPublicFilesystem()
- public Filesystem getPublicFilesystem()
- public $this setProtectedFilesystem()
- public Filesystem getProtectedFilesystem()
- public FileResolutionStrategy getPublicResolutionStrategy()
- public void setPublicResolutionStrategy()
- public FileResolutionStrategy getProtectedResolutionStrategy()
- public void setProtectedResolutionStrategy()
- protected Filesystem getFilesystemFor()
- private mixed applyToFileOnFilesystem()
- private mixed applyToFileIDOnFilesystem()
- public void getCapabilities()
- public void getVisibility()
- public void getAsStream()
- public void getAsString()
- public void getAsURL()
- public void setFromLocalFile()
- public void setFromString()
- public void setFromStream()
- public void delete()
- public void rename()
- public void copy()
- protected bool deleteFromFilesystem()
- protected bool deleteFromFileStore()
- protected void truncateDirectory()
- protected Generator findVariants()
- public void publish()
- public void swapPublish()
- public void protect()
- protected void moveBetweenFilesystems()
- protected void moveBetweenFileStore()
- public void grant()
- public void revoke()
- public void canView()
- protected bool isGranted()
- protected string getStreamSHA1()
- protected string getStreamAsFile()
- protected bool isSeekableStream()
- protected array writeWithCallback()
- protected string getDefaultConflictResolution()
- protected bool useLegacyFilenames()
- public void getMetadata()
- public void getMimeType()
- public void exists()
- protected string|false resolveConflicts()
- protected AssetNameGenerator fileGeneratorFor()
- protected string cleanFilename()
- protected array parseFileID()
- protected string getOriginalFilename()
- protected string getVariant()
- protected string removeVariant()
- protected string getFileID()
- public static void flush()
- public void getResponseFor()
- private array generateResponseFor()
- protected HTTPResponse createResponseFor()
- private HTTPResponse createRedirectResponse()
- protected HTTPResponse createDeniedResponse()
- protected HTTPResponse createMissingResponse()
- protected HTTPResponse createErrorResponse()
- public void normalisePath()
- public void normalise()
- private array normaliseToDefaultPath()
Hierarchy
Uses
- SilverStripe\Core\Config\Configurable
- SilverStripe\Core\Extensible
Implements
- SilverStripe\Assets\Storage\AssetStore
- SilverStripe\Assets\Storage\AssetStoreRouter
- SilverStripe\Core\Flushable
Constants
Name | Value |
---|---|
GRANTS_SESSION | 'AssetStore_Grants' |
CONFLICT_EXCEPTION | 'exception' |
CONFLICT_OVERWRITE | 'overwrite' |
CONFLICT_RENAME | 'rename' |
CONFLICT_USE_EXISTING | 'existing' |
VISIBILITY_PROTECTED | 'protected' |
VISIBILITY_PUBLIC | 'public' |
Members
private
- $denied_response_code
—
int
Set HTTP error code for requests to secure denied assets. - $file_response_headers
—
array
Custom headers to add to all custom file responses - $keep_empty_dirs
—
SilverStripe\Assets\Flysystem\bool
Flag if empty folders are allowed. - $legacy_filenames
—
SilverStripe\Assets\Flysystem\bool
Enable to use legacy filename behaviour (omits hash and uses the natural filename). - $missing_response_code
—
int
Set HTTP error code to use for missing secure assets - $permanent_redirect_response_code
—
int
Define the HTTP Response code for request that should be permanently redirected to a different URL. Defaults to 301. - $protectedFilesystem
—
League\Flysystem\Filesystem
Filesystem to use for protected files - $protectedResolutionStrategy
—
SilverStripe\Assets\FilenameParsing\FileResolutionStrategy
File resolution strategy to use with the protected adapter. - $publicFilesystem — League\Flysystem\Filesystem
- $publicResolutionStrategy
—
SilverStripe\Assets\FilenameParsing\FileResolutionStrategy
File resolution strategy to use with the public adapter. - $redirect_response_code
—
int
Define the HTTP Response code for request that should be temporarily redirected to a different URL. Defaults to 302.
Methods
private
- applyToFileIDOnFilesystem() — Equivalent to `applyToFileOnFilesystem`, only it expects a `fileID1 string instead of a ParsedFileID.
- applyToFileOnFilesystem() — Generic method to apply an action to a file regardless of what FileSystem it's on. The action to perform should be provided as a closure expecting the following signature: ``` function(ParsedFileID $parsedFileID, FileSystem $fs, FileResolutionStrategy $strategy, $visibility) ```
- createRedirectResponse() — Redirect browser to specified file ID on the public store. Assumes an existence check for the fileID has already occured.
- generateResponseFor() — Build a response for getResponseFor along with some context information for the `updateResponse` hook.
- normaliseToDefaultPath() — Given a parsed file ID, move the matching file and all its variants to the default position as defined by the provided strategy.
protected
- cleanFilename() — Performs filename cleanup before sending it back.
- createDeniedResponse() — Generate a response for requests to a denied protected file
- createErrorResponse() — Create a response with the given error code
- createMissingResponse() — Generate a response for missing file requests
- createResponseFor() — Generate an {@see HTTPResponse} for the given file from the source filesystem
- deleteFromFileStore() — Delete the given file (and any variants) in the given {@see Filesystem}
- deleteFromFilesystem() — Delete the given file (and any variants) in the given {@see Filesystem}
- fileGeneratorFor() — Get an asset renamer for the given filename.
- findVariants() — Returns an iterable {@see Generator} of all files / variants for the given $fileID in the given $filesystem This includes the empty (no) variant.
- getDefaultConflictResolution() — Choose a default conflict resolution
- getFileID() — Map file tuple (hash, name, variant) to a filename to be used by flysystem
- getFilesystemFor() — Return the store that contains the given fileID
- getOriginalFilename() — Given a FileID, map this back to the original filename, trimming variant and hash
- getStreamAsFile() — Get stream as a file
- getStreamSHA1() — get sha1 hash from stream
- getVariant() — Get variant from this file
- isGranted() — Determine if a grant exists for the given FileID
- isSeekableStream() — Determine if this stream is seekable
- moveBetweenFileStore() — Move a file and its associated variant from one file store to another adjusting the file name format.
- moveBetweenFilesystems() — Move a file (and its associative variants) between filesystems
- parseFileID() — Get Filename and Variant from FileID
- removeVariant() — Remove variant from a fileID
- resolveConflicts() — Determine the path that should be written to, given the conflict resolution scheme
- truncateDirectory() — Clear directory if it's empty
- useLegacyFilenames() — Determine if legacy filenames should be used. This no longuer makes any difference with the introduction of FileResolutionStrategies.
- writeWithCallback() — Invokes the conflict resolution scheme on the given content, and invokes a callback if the storage request is approved.
public
- canView()
- copy()
- delete()
- exists()
- flush() — Ensure each adapter re-generates its own server configuration files
- getAsStream()
- getAsString()
- getAsURL()
- getCapabilities()
- getMetadata()
- getMimeType()
- getProtectedFilesystem() — Get filesystem to use for non-public files
- getProtectedResolutionStrategy()
- getPublicFilesystem() — Get the currently assigned flysystem backend
- getPublicResolutionStrategy()
- getResponseFor()
- getVisibility()
- grant()
- normalise()
- normalisePath()
- protect()
- publish()
- rename()
- revoke()
- setFromLocalFile()
- setFromStream()
- setFromString()
- setProtectedFilesystem() — Assign filesystem to use for non-public files
- setProtectedResolutionStrategy()
- setPublicFilesystem() — Assign new flysystem backend
- setPublicResolutionStrategy()
- swapPublish() — Similar to publish, only any existing files that would be overriden by publishing will be moved back to the protected store.