TestingAssetsTrait
Trait TestingAssetsTrait
Table of Contents
Methods
- addDir() : $this
- Add all assets matching $pattern within $directory.
- addDirCss() : $this
- Add all CSS assets within $directory
- addDirJs() : $this
- Add all JavaScript assets within $directory
- exists() : bool
- Determines if an asset exists as a collection, CSS or JS reference
- getCollections() : array<string|int, mixed>
- Return the array of all the registered collections
- getCss() : array<string|int, mixed>
- Return the array of all the registered CSS assets If a $key is provided, it will try to return only that asset else it will return null
- getJs() : array<string|int, mixed>
- Return the array of all the registered JS assets If a $key is provided, it will try to return only that asset else it will return null
- getTimestamp() : string|null
- Get the timestamp for assets
- removeCss() : $this
- Removes an item from the CSS array if set
- removeJs() : $this
- Removes an item from the JS array if set
- reset() : $this
- Reset all assets.
- resetCss() : $this
- Reset CSS assets.
- resetJs() : $this
- Reset JavaScript assets.
- setCollection() : $this
- Set the array of collections explicitly
- setCss() : $this
- Set the whole array of CSS assets
- setCssPipeline() : $this
- Sets the state of CSS Pipeline
- setJs() : $this
- Set the whole array of JS assets
- setJsPipeline() : $this
- Sets the state of JS Pipeline
- setTimestamp() : mixed
- Explicitly set's a timestamp for assets
- rglob() : array<string|int, mixed>
- Recursively get files matching $pattern within $directory.
Methods
addDir()
Add all assets matching $pattern within $directory.
public
addDir(string $directory[, string $pattern = self::DEFAULT_REGEX ]) : $this
Parameters
- $directory : string
-
Relative to the Grav root path, or a stream identifier
- $pattern : string = self::DEFAULT_REGEX
-
(regex)
Return values
$thisaddDirCss()
Add all CSS assets within $directory
public
addDirCss(string $directory) : $this
Parameters
- $directory : string
-
Relative to the Grav root path, or a stream identifier
Return values
$thisaddDirJs()
Add all JavaScript assets within $directory
public
addDirJs(string $directory) : $this
Parameters
- $directory : string
-
Relative to the Grav root path, or a stream identifier
Return values
$thisexists()
Determines if an asset exists as a collection, CSS or JS reference
public
exists(string $asset) : bool
Parameters
- $asset : string
Return values
boolgetCollections()
Return the array of all the registered collections
public
getCollections() : array<string|int, mixed>
Return values
array<string|int, mixed>getCss()
Return the array of all the registered CSS assets If a $key is provided, it will try to return only that asset else it will return null
public
getCss([string|null $key = null ]) : array<string|int, mixed>
Parameters
- $key : string|null = null
-
the asset key
Return values
array<string|int, mixed>getJs()
Return the array of all the registered JS assets If a $key is provided, it will try to return only that asset else it will return null
public
getJs([string|null $key = null ]) : array<string|int, mixed>
Parameters
- $key : string|null = null
-
the asset key
Return values
array<string|int, mixed>getTimestamp()
Get the timestamp for assets
public
getTimestamp([bool $include_join = true ]) : string|null
Parameters
- $include_join : bool = true
Return values
string|nullremoveCss()
Removes an item from the CSS array if set
public
removeCss(string $key) : $this
Parameters
- $key : string
-
The asset key
Return values
$thisremoveJs()
Removes an item from the JS array if set
public
removeJs(string $key) : $this
Parameters
- $key : string
-
The asset key
Return values
$thisreset()
Reset all assets.
public
reset() : $this
Return values
$thisresetCss()
Reset CSS assets.
public
resetCss() : $this
Return values
$thisresetJs()
Reset JavaScript assets.
public
resetJs() : $this
Return values
$thissetCollection()
Set the array of collections explicitly
public
setCollection(array<string|int, mixed> $collections) : $this
Parameters
- $collections : array<string|int, mixed>
Return values
$thissetCss()
Set the whole array of CSS assets
public
setCss(array<string|int, mixed> $css) : $this
Parameters
- $css : array<string|int, mixed>
Return values
$thissetCssPipeline()
Sets the state of CSS Pipeline
public
setCssPipeline(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetJs()
Set the whole array of JS assets
public
setJs(array<string|int, mixed> $js) : $this
Parameters
- $js : array<string|int, mixed>
Return values
$thissetJsPipeline()
Sets the state of JS Pipeline
public
setJsPipeline(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetTimestamp()
Explicitly set's a timestamp for assets
public
setTimestamp(string|int $value) : mixed
Parameters
- $value : string|int
rglob()
Recursively get files matching $pattern within $directory.
protected
rglob(string $directory, string $pattern[, string|null $ltrim = null ]) : array<string|int, mixed>
Parameters
- $directory : string
- $pattern : string
-
(regex)
- $ltrim : string|null = null
-
Will be trimmed from the left of the file path