Documentation

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
$this

addDirCss()

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
$this

addDirJs()

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
$this

exists()

Determines if an asset exists as a collection, CSS or JS reference

public exists(string $asset) : bool
Parameters
$asset : string
Return values
bool

getCollections()

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|null

removeCss()

Removes an item from the CSS array if set

public removeCss(string $key) : $this
Parameters
$key : string

The asset key

Return values
$this

removeJs()

Removes an item from the JS array if set

public removeJs(string $key) : $this
Parameters
$key : string

The asset key

Return values
$this

resetJs()

Reset JavaScript assets.

public resetJs() : $this
Return values
$this

setCollection()

Set the array of collections explicitly

public setCollection(array<string|int, mixed> $collections) : $this
Parameters
$collections : array<string|int, mixed>
Return values
$this

setCss()

Set the whole array of CSS assets

public setCss(array<string|int, mixed> $css) : $this
Parameters
$css : array<string|int, mixed>
Return values
$this

setCssPipeline()

Sets the state of CSS Pipeline

public setCssPipeline(bool $value) : $this
Parameters
$value : bool
Return values
$this

setJs()

Set the whole array of JS assets

public setJs(array<string|int, mixed> $js) : $this
Parameters
$js : array<string|int, mixed>
Return values
$this

setJsPipeline()

Sets the state of JS Pipeline

public setJsPipeline(bool $value) : $this
Parameters
$value : bool
Return values
$this

setTimestamp()

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

Return values
array<string|int, mixed>

        
On this page

Search results