SilverStripe\Assets\Dev\TestAssetStore
Allows you to mock a backend store in a custom directory beneath assets.
Only to be used for mocking test fixtures
Synopsis
class TestAssetStore
extends FlysystemAssetStore
implements
TestOnly
{
- // Inherited constants from FlysystemAssetStore
- const GRANTS_SESSION = 'AssetStore_Grants';
- // members
- private static integer $denied_response_code = 403;
- public static null|bool $seekable_override = NULL;
- public static $basedir = NULL;
- // methods
- public static void activate()
- public static string base_path()
- public static void reset()
- public static string getLocalPath()
- public void cleanFilename()
- public void getFileID()
- public void parseFileID()
- public void getOriginalFilename()
- public void getFilesystemFor()
- public void removeVariant()
- public void getDefaultConflictResolution()
- public void isGranted()
- protected void isSeekableStream()
- // Inherited methods from FlysystemAssetStore
- 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()
- 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()
- protected HTTPResponse createResponseFor()
- protected HTTPResponse createDeniedResponse()
- protected HTTPResponse createMissingResponse()
- protected HTTPResponse createErrorResponse()
- public void normalisePath()
- public void normalise()
Hierarchy
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
Enable disclosure of secure assets
public
- $basedir
—
string
Base dir of current file - $seekable_override
—
SilverStripe\Assets\Dev\null|bool
Set to true|false to override all isSeekableStream calls
Methods
protected
public
- activate() — Set this store as the new asset backend
- base_path() — Get absolute path to basedir
- cleanFilename()
- getDefaultConflictResolution()
- getFileID()
- getFilesystemFor()
- getLocalPath() — Helper method to get local filesystem path for this file
- getOriginalFilename()
- isGranted() — Allows testing of grant status
- parseFileID()
- removeVariant()
- reset() — Reset defaults for this store
Inherited from SilverStripe\Assets\Flysystem\FlysystemAssetStore
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.