AssetContainer
interface AssetContainer (View source)
Represents a container for a specific asset.
This is used as a use-agnostic interface to a single asset backed by an AssetStore
Note that there are no setter equivalents for each of getHash, getVariant and getFilename. User code should utilise the setFrom* methods instead.
Methods
Assign a set of data to the backend
Assign a local file to the backend.
Assign a stream to the backend
No description
No description
No description
No description
Get metadata for this file
Get mime type
Return file size in bytes.
Determine if a valid non-empty image exists behind this asset
Determine visibility of the given file
Determine if this container has a valid value
Get value of filename
Get value of hash
Get value of variant
Delete a file (and all variants).
Rename to new filename, and point to new file
Copy to new filename.
Publicly expose the file (and all variants) identified by the given filename and hash {see AssetStore::publish}
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.
Details
array
setFromString(string $data, string $filename, string $hash = null, string $variant = null, array $config = [])
Assign a set of data to the backend
array
setFromLocalFile(string $path, string $filename = null, string $hash = null, string $variant = null, array $config = [])
Assign a local file to the backend.
array
setFromStream(resource $stream, string $filename, string $hash = null, string $variant = null, array $config = [])
Assign a stream to the backend
string
getString()
resource
getStream()
string
getURL(bool $grant = true)
string
getAbsoluteURL()
array|null
getMetaData()
Get metadata for this file
string
getMimeType()
Get mime type
int
getAbsoluteSize()
Return file size in bytes.
bool
getIsImage()
Determine if a valid non-empty image exists behind this asset
string
getVisibility()
Determine visibility of the given file
bool
exists()
Determine if this container has a valid value
string
getFilename()
Get value of filename
string
getHash()
Get value of hash
string
getVariant()
Get value of variant
bool
deleteFile()
Delete a file (and all variants).
{see \SilverStripe\Assets\Storage\AssetStore::delete()}
string
renameFile(string $newName)
Rename to new filename, and point to new file
string
copyFile(string $newName)
Copy to new filename.
This will not automatically point to the new file (as renameFile() does)
publishFile()
Publicly expose the file (and all variants) identified by the given filename and hash {see AssetStore::publish}
protectFile()
Protect a file (and all variants) from public access, identified by the given filename and hash.
{see \SilverStripe\Assets\Storage\AssetStore::protect()}
grantFile()
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.
revokeFile()
Revoke access to the given file for the current user.
Note: This will have no effect if the given file is public
bool
canViewFile()
Check if the current user can view the given file.