AssetInterface
in
An asset has a mutable URL and content and can be loaded and dumped.
Tags
Table of Contents
- clearFilters() : mixed
- Clears all filters from the current asset.
- dump() : string
- Applies dump filters and returns the asset as a string.
- ensureFilter() : mixed
- Ensures the current asset includes the supplied filter.
- getContent() : string
- Returns the loaded content of the current asset.
- getFilters() : array<string|int, mixed>
- Returns an array of filters currently applied.
- getLastModified() : int|null
- Returns the time the current asset was last modified.
- getSourceDirectory() : string|null
- Returns the asset's source directory.
- getSourcePath() : string|null
- Returns the relative path for the source asset.
- getSourceRoot() : string|null
- Returns an absolute path or URL to the source asset's root directory.
- getTargetPath() : string|null
- Returns the URL for the current asset.
- getValues() : array<string|int, mixed>
- Returns the current values for this asset.
- getVars() : array<string|int, mixed>
- Returns an array of variable names for this asset.
- load() : mixed
- Loads the asset into memory and applies load filters.
- setContent() : mixed
- Sets the content of the current asset.
- setTargetPath() : mixed
- Sets the URL for the current asset.
- setValues() : mixed
- Sets the values for the asset's variables.
Methods
clearFilters()
Clears all filters from the current asset.
public
clearFilters() : mixed
Return values
mixed —dump()
Applies dump filters and returns the asset as a string.
public
dump([FilterInterface $additionalFilter = null ]) : string
You may provide an additional filter to apply during dump.
Dumping an asset should not change its state.
If the current asset has not been loaded yet, it should be automatically loaded at this time.
Parameters
- $additionalFilter : FilterInterface = null
-
An additional filter
Return values
string —The filtered content of the current asset
ensureFilter()
Ensures the current asset includes the supplied filter.
public
ensureFilter(FilterInterface $filter) : mixed
Parameters
- $filter : FilterInterface
-
A filter
Return values
mixed —getContent()
Returns the loaded content of the current asset.
public
getContent() : string
Return values
string —The content
getFilters()
Returns an array of filters currently applied.
public
getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed> —An array of filters
getLastModified()
Returns the time the current asset was last modified.
public
getLastModified() : int|null
Return values
int|null —A UNIX timestamp
getSourceDirectory()
Returns the asset's source directory.
public
getSourceDirectory() : string|null
The source directory is the directory the asset was located in and can be used to resolve references relative to an asset.
Return values
string|null —The asset's source directory
getSourcePath()
Returns the relative path for the source asset.
public
getSourcePath() : string|null
This value can be combined with the asset's source root (if both are non-null) to get something compatible with file_get_contents().
For example:
- 'js/main.js'
- 'main.js'
- null
Return values
string|null —The source asset path
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
public
getSourceRoot() : string|null
This value should be an absolute path to a directory in the filesystem, an absolute URL with no path, or null.
For example:
- '/path/to/web'
- 'http://example.com'
- null
Return values
string|null —The asset's root
getTargetPath()
Returns the URL for the current asset.
public
getTargetPath() : string|null
Return values
string|null —A web URL where the asset will be dumped
getValues()
Returns the current values for this asset.
public
getValues() : array<string|int, mixed>
Return values
array<string|int, mixed> —an array of strings
getVars()
Returns an array of variable names for this asset.
public
getVars() : array<string|int, mixed>
Return values
array<string|int, mixed> —load()
Loads the asset into memory and applies load filters.
public
load([FilterInterface $additionalFilter = null ]) : mixed
You may provide an additional filter to apply during load.
Parameters
- $additionalFilter : FilterInterface = null
-
An additional filter
Return values
mixed —setContent()
Sets the content of the current asset.
public
setContent(string $content) : mixed
Filters can use this method to change the content of the asset.
Parameters
- $content : string
-
The asset content
Return values
mixed —setTargetPath()
Sets the URL for the current asset.
public
setTargetPath(string $targetPath) : mixed
Parameters
- $targetPath : string
-
A web URL where the asset will be dumped
Return values
mixed —setValues()
Sets the values for the asset's variables.
public
setValues(array<string|int, mixed> $values) : mixed
Parameters
- $values : array<string|int, mixed>