Documentation

StringAsset extends BaseAsset
in package

Represents a string asset.

Tags
author

Kris Wallsmith kris.wallsmith@gmail.com

Table of Contents

$content  : mixed
$filters  : mixed
$lastModified  : mixed
$loaded  : mixed
$sourceDir  : mixed
$sourcePath  : mixed
$sourceRoot  : mixed
$string  : mixed
$targetPath  : mixed
$values  : mixed
$vars  : mixed
__clone()  : mixed
__construct()  : mixed
Constructor.
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()  : mixed
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
setContent()  : mixed
Sets the content of the current asset.
setLastModified()  : mixed
setTargetPath()  : mixed
Sets the URL for the current asset.
setValues()  : mixed
Sets the values for the asset's variables.
doLoad()  : mixed
Encapsulates asset loading logic.

Properties

Methods

__clone()

public __clone() : mixed
Return values
mixed

__construct()

Constructor.

public __construct(string $content[, array<string|int, mixed> $filters = array() ][, string $sourceRoot = null ][, string $sourcePath = null ]) : mixed
Parameters
$content : string

The content of the asset

$filters : array<string|int, mixed> = array()

Filters for the asset

$sourceRoot : string = null

The source asset root directory

$sourcePath : string = null

The source asset path

Return values
mixed

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()

public getLastModified() : mixed
Return values
mixed

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>

setContent()

Sets the content of the current asset.

public setContent(mixed $content) : mixed

Filters can use this method to change the content of the asset.

Parameters
$content : mixed

The asset content

Return values
mixed

setLastModified()

public setLastModified(mixed $lastModified) : mixed
Parameters
$lastModified : mixed
Return values
mixed

setTargetPath()

Sets the URL for the current asset.

public setTargetPath(mixed $targetPath) : mixed
Parameters
$targetPath : mixed

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>
Return values
mixed

doLoad()

Encapsulates asset loading logic.

protected doLoad(string $content[, FilterInterface $additionalFilter = null ]) : mixed
Parameters
$content : string

The asset content

$additionalFilter : FilterInterface = null

An additional filter

Return values
mixed

Search results