StringAsset
class StringAsset extends BaseAsset
Represents a string asset.
Properties
private | $filters | from BaseAsset | |
private | $sourceRoot | from BaseAsset | |
private | $sourcePath | from BaseAsset | |
private | $sourceDir | from BaseAsset | |
private | $targetPath | from BaseAsset | |
private | $content | from BaseAsset | |
private | $loaded | from BaseAsset | |
private | $vars | from BaseAsset | |
private | $values | from BaseAsset | |
private | $string | ||
private | $lastModified |
Methods
Constructor.
Applies dump filters and returns the asset as a string.
Returns an absolute path or URL to the source asset's root directory.
Loads the asset into memory and applies load filters.
No description
Returns the time the current asset was last modified.
Details
at line 35
__construct(string $content, array $filters = [], string $sourceRoot = null, string $sourcePath = null)
Constructor.
in
BaseAsset at line 66
__clone()
No description
in
BaseAsset at line 71
ensureFilter(FilterInterface $filter)
Ensures the current asset includes the supplied filter.
in
BaseAsset at line 76
array
getFilters()
Returns an array of filters currently applied.
in
BaseAsset at line 81
clearFilters()
Clears all filters from the current asset.
in
BaseAsset at line 92
protected
doLoad(string $content, FilterInterface $additionalFilter = null)
Encapsulates asset loading logic.
in
BaseAsset at line 108
string
dump(FilterInterface $additionalFilter = null)
Applies dump filters and returns the asset as a 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.
in
BaseAsset at line 125
string
getContent()
Returns the loaded content of the current asset.
in
BaseAsset at line 130
setContent(string $content)
Sets the content of the current asset.
Filters can use this method to change the content of the asset.
in
BaseAsset at line 135
string|null
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
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
in
BaseAsset at line 140
string|null
getSourcePath()
Returns the relative path for the source asset.
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
in
BaseAsset at line 145
string|null
getSourceDirectory()
Returns the asset's source directory.
The source directory is the directory the asset was located in and can be used to resolve references relative to an asset.
in
BaseAsset at line 150
string|null
getTargetPath()
Returns the URL for the current asset.
in
BaseAsset at line 155
setTargetPath(string $targetPath)
Sets the URL for the current asset.
in
BaseAsset at line 168
array
getVars()
Returns an array of variable names for this asset.
in
BaseAsset at line 173
setValues(array $values)
Sets the values for the asset's variables.
in
BaseAsset at line 185
array
getValues()
Returns the current values for this asset.
at line 42
load(FilterInterface $additionalFilter = null)
Loads the asset into memory and applies load filters.
You may provide an additional filter to apply during load.
at line 47
setLastModified($lastModified)
No description
at line 52
int|null
getLastModified()
Returns the time the current asset was last modified.