phpDocumentor

AssetCollection extends AbstractCollection
in package
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.

Tags
category

System

subpackage

Collections

Interfaces, Classes and Traits

AssetCollectionInterface
Interface AssetCollectionInterface

Table of Contents

$collectionContentArray  : array<string|int, mixed>
Content Collection
__construct()  : mixed
Initialize the collection instance.
add()  : mixed
Adds a new asset to the collection.
count()  : int
Get collection item count.
getArray()  : array<string|int, mixed>
Get the collection as an array.
getHtml()  : string
Prints the HTML markup for the assets.
getItem()  : mixed
Get specific collection item by index.
getIterator()  : Traversable
getTranslations()  : array<string|int, mixed>
Get all the translation assets as one array.
isEmpty()  : bool
Determine whether the collection is empty or not.
_add()  : mixed
Add a new item.
_getExceptionText()  : string
Get exception text.
_getValidType()  : string
Returns the type of the collection items.
_itemIsValid()  : bool
Check if a new item has the valid collection type.

Properties

$collectionContentArray

Content Collection

protected array<string|int, mixed> $collectionContentArray = []

Methods

__construct()

Initialize the collection instance.

public __construct([array<string|int, mixed>|mixed|null $argumentsArray = null ]) : mixed
Parameters
$argumentsArray : array<string|int, mixed>|mixed|null = null
Tags
throws
InvalidArgumentException
Return values
mixed

getArray()

Get the collection as an array.

public getArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHtml()

Prints the HTML markup for the assets.

public getHtml([StringType $type = null ]) : string
Parameters
$type : StringType = null

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

Return values
string

Returns the HTML markup of the assets.

getItem()

Get specific collection item by index.

public getItem( $p_index) : mixed
Parameters
$p_index :
Tags
throws
InvalidArgumentException

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

Return values
mixed

getTranslations()

Get all the translation assets as one array.

public getTranslations() : array<string|int, mixed>

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

Return values
array<string|int, mixed>

isEmpty()

Determine whether the collection is empty or not.

public isEmpty() : bool
Return values
bool

_add()

Add a new item.

protected _add(mixed $item) : mixed

This method must be used by child-collection classes.

Parameters
$item : mixed

Item which should add to the collection

Tags
throws
InvalidArgumentException

When $item has an invalid type.

Return values
mixed

_getExceptionText()

Get exception text.

protected _getExceptionText() : string
Return values
string

_getValidType()

Returns the type of the collection items.

protected _getValidType() : string
Return values
string

_itemIsValid()

Check if a new item has the valid collection type.

protected _itemIsValid(mixed $dataItem) : bool
Parameters
$dataItem : mixed
Return values
bool

Search results