class GlobAsset extends AssetCollection

A collection of assets loaded by glob.

Properties

private $assets from  AssetCollection
private $filters from  AssetCollection
private $sourceRoot from  AssetCollection
private $targetPath from  AssetCollection
private $content from  AssetCollection
private $clones from  AssetCollection
private $vars from  AssetCollection
private $values from  AssetCollection
private $globs
private $initialized

Methods

__construct(string|array $globs, array $filters = [], string $root = null, array $vars = [])

Constructor.

__clone()

No description

array
all()

Returns all child assets.

add(AssetInterface $asset)

Adds an asset to the current collection.

bool
removeLeaf(AssetInterface $needle, bool $graceful = false)

Removes a leaf.

bool
replaceLeaf(AssetInterface $needle, AssetInterface $replacement, bool $graceful = false)

Replaces an existing leaf with a new one.

ensureFilter(FilterInterface $filter)

Ensures the current asset includes the supplied filter.

array
getFilters()

Returns an array of filters currently applied.

clearFilters()

Clears all filters from the current asset.

load(FilterInterface $additionalFilter = null)

Loads the asset into memory and applies load filters.

string
dump(FilterInterface $additionalFilter = null)

Applies dump filters and returns the asset as a string.

string
getContent()

Returns the loaded content of the current asset.

setContent(string $content)

Sets the content of the current asset.

string|null
getSourceRoot()

Returns an absolute path or URL to the source asset's root directory.

string|null
getSourcePath()

Returns the relative path for the source asset.

string|null
getSourceDirectory()

Returns the asset's source directory.

string|null
getTargetPath()

Returns the URL for the current asset.

setTargetPath(string $targetPath)

Sets the URL for the current asset.

int|null
getLastModified()

Returns the highest last-modified value of all assets in the current collection.

getIterator()

Returns an iterator for looping recursively over unique leaves.

array
getVars()

Returns an array of variable names for this asset.

setValues(array $values)

Sets the values for the asset's variables.

array
getValues()

Returns the current values for this asset.

initialize()

Initializes the collection based on the glob(s) passed in.

Details

at line 35
__construct(string|array $globs, array $filters = [], string $root = null, array $vars = [])

Constructor.

Parameters

string|array $globs

A single glob path or array of paths

array $filters

Filters for the current collection

string $root

The root directory

array $vars

in AssetCollection at line 64
__clone()

No description

at line 43
array all()

Returns all child assets.

Return Value

array

An array of AssetInterface objects

in AssetCollection at line 75
add(AssetInterface $asset)

Adds an asset to the current collection.

Parameters

AssetInterface $asset

An asset

in AssetCollection at line 80
bool removeLeaf(AssetInterface $needle, bool $graceful = false)

Removes a leaf.

Parameters

AssetInterface $needle
bool $graceful

Whether the failure should return false or throw an exception

Return Value

bool

Whether the asset has been found

Exceptions

InvalidArgumentException

in AssetCollection at line 102
bool replaceLeaf(AssetInterface $needle, AssetInterface $replacement, bool $graceful = false)

Replaces an existing leaf with a new one.

Parameters

AssetInterface $needle

The current asset to replace

AssetInterface $replacement

The new asset

bool $graceful

Whether the failure should return false or throw an exception

Return Value

bool

Whether the asset has been found

Exceptions

InvalidArgumentException

in AssetCollection at line 125
ensureFilter(FilterInterface $filter)

Ensures the current asset includes the supplied filter.

Parameters

FilterInterface $filter

A filter

in AssetCollection at line 130
array getFilters()

Returns an array of filters currently applied.

Return Value

array

An array of filters

in AssetCollection at line 135
clearFilters()

Clears all filters from the current asset.

at line 52
load(FilterInterface $additionalFilter = null)

Loads the asset into memory and applies load filters.

You may provide an additional filter to apply during load.

Parameters

FilterInterface $additionalFilter

An additional filter

at line 61
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.

Parameters

FilterInterface $additionalFilter

An additional filter

Return Value

string

The filtered content of the current asset

in AssetCollection at line 164
string getContent()

Returns the loaded content of the current asset.

Return Value

string

The content

in AssetCollection at line 169
setContent(string $content)

Sets the content of the current asset.

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

Parameters

string $content

The asset content

in AssetCollection at line 174
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:

Return Value

string|null

The asset's root

in AssetCollection at line 179
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

Return Value

string|null

The source asset path

in AssetCollection at line 183
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.

Return Value

string|null

The asset's source directory

in AssetCollection at line 187
string|null getTargetPath()

Returns the URL for the current asset.

Return Value

string|null

A web URL where the asset will be dumped

in AssetCollection at line 192
setTargetPath(string $targetPath)

Sets the URL for the current asset.

Parameters

string $targetPath

A web URL where the asset will be dumped

at line 70
int|null getLastModified()

Returns the highest last-modified value of all assets in the current collection.

Return Value

int|null

A UNIX timestamp

at line 79
getIterator()

Returns an iterator for looping recursively over unique leaves.

in AssetCollection at line 227
array getVars()

Returns an array of variable names for this asset.

Return Value

array

at line 88
setValues(array $values)

Sets the values for the asset's variables.

Parameters

array $values

in AssetCollection at line 241
array getValues()

Returns the current values for this asset.

Return Value

array

an array of strings

at line 97
private initialize()

Initializes the collection based on the glob(s) passed in.