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
Publicly expose the file (and all variants) identified by the given filename and hash {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.
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()
        
    
    No description
        
                            resource
    getStream()
        
    
    No description
        
                            string
    getURL(bool $grant = true)
        
    
    No description
        
                            string
    getAbsoluteURL()
        
    
    No description
        
                            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).
        
                            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 {AssetStore::publish}
        
                            
    protectFile()
        
    
    Protect a file (and all variants) from public access, identified by the given filename and hash.
        
                            
    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.