AssetCollection

Extends \AbstractCollection Implements \AssetCollectionInterface

Class AssetCollection

Handles Asset objects (JavaScript and CSS). Use the getHtml() method to get the HTML output for the collection. The elements will be outputted in the same order they were added in the collection.

category

System

package

Http

subpackage

Collections

Methods

Initialize the collection instance.

__construct(array|mixed|null $argumentsArray = null) 
inherited
Throws
\InvalidArgumentException

Arguments

$argumentsArray

array|mixed|null

Add a new item.

_add(mixed $item) 
inherited

This method must be used by child-collection classes.

Throws
\InvalidArgumentException

When $item has an invalid type.

Arguments

$item

mixed

Item which should add to the collection

Get exception text.

_getExceptionText() : string
inherited

Response

string

Get valid type.

_getValidType() : string
inherited abstract

This method must be implemented in the child-collection classes.

Response

string

Check if a new item has the valid collection type.

_itemIsValid(mixed $dataItem) : boolean
inherited

Arguments

$dataItem

mixed

Response

boolean

Adds a new asset to the collection.

add(\AssetInterface $asset) 

Arguments

Get collection item count.

count() : integer
inherited

Response

integer

Get the collection as an array.

getArray() : array
inherited

Response

array

Prints the HTML markup for the assets.

getHtml(\StringType $type = null) : string

Arguments

$type

\StringType

(optional) You can provide either Asset::JAVASCRIPT, Asset::CSS or Asset::TRANSLATION in order to get the HTML only for a specific type of assets.

Response

string

Returns the HTML markup of the assets.

Get specific collection item by index.

getItem( $p_index) : mixed
inherited
Throws
\InvalidArgumentException

if index is not numeric | OutOfBoundsException if index is out of bounds

Arguments

$p_index

Response

mixed

getIterator

getIterator() 
inherited

Get all the translation assets as one array.

getTranslations() : array

This array can then be used in frontend from JavaScript (JS Engine or plain scripts).

Response

array

Determine whether the collection is empty or not.

isEmpty() : boolean
inherited

Response

boolean

Properties

Content Collection

collectionContentArray : array
inherited
var

Type(s)

array