TestAssetStore
class TestAssetStore extends FlysystemAssetStore implements TestOnly
Allows you to mock a backend store in a custom directory beneath assets.
Only to be used for mocking test fixtures
Traits
Constants
GRANTS_SESSION |
Session key to use for user grants |
Config options
denied_response_code | int | Enable disclosure of secure assets |
Properties
static null|bool | $seekable_override | Set to true|false to override all isSeekableStream calls | |
static string | $basedir | Base dir of current file |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
Gets the uninherited value for the given config option
Assign new flysystem backend
Get the currently assigned flysystem backend
Assign filesystem to use for non-public files
Get filesystem to use for non-public files
Return list of feature capabilities of this backend as an array.
Determine visibility of the given file
Get a stream for this file
Get contents of a given file
Get the url for the file
Assign a local file to the backend.
Assign a set of data to the backend
Assign a stream to the backend
Delete a file (and all variants) identified by the given filename and hash
Rename a file (and all variants) to a new filename
Copy a file (and all variants) to a new filename
Publicly expose the file (and all variants) identified by the given filename and hash
Similar to publish, only any existing files that would be overriden by publishing will be moved back to the protected store.
Protect a file (and all variants) from public access, identified by the given filename and hash.
Ensures that access to the specified protected file is granted for the current user.
Revoke access to the given file for the current user.
Check if the current user can view the given file.
Get metadata for this file, if available
Get mime type of this file
Determine if a file exists with the given tuple
Ensure each adapter re-generates its own server configuration files
Generate a custom HTTP response for a request to a given asset, identified by a path.
Set this store as the new asset backend
Get absolute path to basedir
Reset defaults for this store
Helper method to get local filesystem path for this file
No description
No description
No description
No description
No description
No description
No description
Details
in Configurable at line 20
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in Configurable at line 32
mixed
stat(string $name)
deprecated
deprecated 5.0 Use ->config()->get() instead
Get inherited config value
in Configurable at line 44
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
in Configurable at line 57
$this
set_stat(string $name, mixed $value)
deprecated
deprecated 5.0 Use ->config()->set() instead
Update the config value for a given property
in FlysystemAssetStore at line 146
$this
setPublicFilesystem(Filesystem $filesystem)
Assign new flysystem backend
in FlysystemAssetStore at line 161
Filesystem
getPublicFilesystem()
Get the currently assigned flysystem backend
in FlysystemAssetStore at line 176
$this
setProtectedFilesystem(Filesystem $filesystem)
Assign filesystem to use for non-public files
in FlysystemAssetStore at line 191
Filesystem
getProtectedFilesystem()
Get filesystem to use for non-public files
in FlysystemAssetStore at line 428
array
getCapabilities()
Return list of feature capabilities of this backend as an array.
Array keys will be the options supported by $config, and the values will be the list of accepted values for each option (or true if any value is allowed).
in FlysystemAssetStore at line 444
string
getVisibility(string $filename, string $hash)
Determine visibility of the given file
in FlysystemAssetStore at line 454
resource
getAsStream(string $filename, string $hash, string|null $variant = null)
Get a stream for this file
in FlysystemAssetStore at line 464
string
getAsString(string $filename, string $hash, string|null $variant = null)
Get contents of a given file
in FlysystemAssetStore at line 474
string
getAsURL(string $filename, string $hash, string|null $variant = null, bool $grant = true)
Get the url for the file
in FlysystemAssetStore at line 503
array
setFromLocalFile(string $path, string $filename = null, string $hash = null, string $variant = null, array $config = array())
Assign a local file to the backend.
in FlysystemAssetStore at line 529
array
setFromString(string $data, string $filename, string $hash = null, string $variant = null, array $config = array())
Assign a set of data to the backend
in FlysystemAssetStore at line 543
array
setFromStream(resource $stream, string $filename, string $hash = null, string $variant = null, array $config = array())
Assign a stream to the backend
in FlysystemAssetStore at line 593
bool
delete(string $filename, string $hash)
Delete a file (and all variants) identified by the given filename and hash
in FlysystemAssetStore at line 608
string
rename(string $filename, string $hash, string $newName)
Rename a file (and all variants) to a new filename
in FlysystemAssetStore at line 657
string|null
copy(string $filename, string $hash, string $newName)
Copy a file (and all variants) to a new filename
in FlysystemAssetStore at line 782
publish(string $filename, string $hash)
Publicly expose the file (and all variants) identified by the given filename and hash
in FlysystemAssetStore at line 808
swapPublish($filename, $hash)
Similar to publish, only any existing files that would be overriden by publishing will be moved back to the protected store.
in FlysystemAssetStore at line 879
protect(string $filename, string $hash)
Protect a file (and all variants) from public access, identified by the given filename and hash.
A protected file can be granted access to users on a per-session or per-user basis as response to any future invocations of {see grant()} or {see getAsURL()} with $grant = true
in FlysystemAssetStore at line 966
grant(string $filename, string $hash)
Ensures that access to the specified protected file is granted for the current user.
If this file is currently in protected mode, the asset store will ensure the returned asset for the duration of the current session / user. This will have no effect if the file is in published mode. This will not grant access to users other than the owner of the current session. Does not require a member to be logged in.
in FlysystemAssetStore at line 977
revoke(string $filename, string $hash)
Revoke access to the given file for the current user.
Note: This will have no effect if the given file is public
in FlysystemAssetStore at line 994
bool
canView(string $filename, string $hash)
Check if the current user can view the given file.
in FlysystemAssetStore at line 1209
array|null
getMetadata(string $filename, string $hash, string|null $variant = null)
Get metadata for this file, if available
in FlysystemAssetStore at line 1220
string
getMimeType(string $filename, string $hash, string|null $variant = null)
Get mime type of this file
in FlysystemAssetStore at line 1231
bool
exists(string $filename, string $hash, string|null $variant = null)
Determine if a file exists with the given tuple
in FlysystemAssetStore at line 1427
static
flush()
Ensure each adapter re-generates its own server configuration files
in FlysystemAssetStore at line 1450
HTTPResponse
getResponseFor(string $asset)
Generate a custom HTTP response for a request to a given asset, identified by a path.
in FlysystemAssetStore at line 1577
normalisePath($fileID)
in FlysystemAssetStore at line 1587
normalise($filename, $hash)
at line 59
static
activate(string $basedir)
Set this store as the new asset backend
at line 108
static string
base_path()
Get absolute path to basedir
at line 119
static
reset()
Reset defaults for this store
at line 140
static string
getLocalPath(AssetContainer $asset, boolean $forceProtected = false, boolean $relative = false)
Helper method to get local filesystem path for this file