class ResponseAssetGroup (View source)

Properties

static protected ResponseAssetGroup|null $group
protected AssetPointer[] $providedAssetGroupUnmatched
protected array $outputAssets

Methods

get()

Get an instance of this singleton.

__construct()

No description

init()

No description

addHeaderAsset(Asset $item)

Add an asset that should be loaded in the header.

addFooterAsset(Asset $item)

Add an asset that should be loaded in the footer.

addOutputAsset(Asset $asset)

Add an asset at the position that's defined in the asset.

addOutputAssetAt(Asset $item, string $position)

Add an asset at a specific position.

getAssetsToOutput()

Get a list of assets that need to be outputted.

markAssetAsIncluded(string $assetType, string|false $assetHandle = false)

Notes in the current request that a particular asset has already been provided.

requireAsset(AssetGroup|Asset|string $assetType, string|false $assetHandle = false)

Adds a required asset to this request. This asset will attempt to be output or included when a view is rendered.

getRequiredAssets()

Returns all required assets.

bool
filterProvidedAssets(Asset $asset)

No description

Asset[]
getRequiredAssetsToOutput()

Returns only assets that are required but that aren't also in the providedAssetGroup.

Details

static ResponseAssetGroup get()

Get an instance of this singleton.

Return Value

ResponseAssetGroup

__construct()

No description

init()

No description

addHeaderAsset(Asset $item)

Add an asset that should be loaded in the header.

Parameters

Asset $item

addFooterAsset(Asset $item)

Add an asset that should be loaded in the footer.

Parameters

Asset $item

addOutputAsset(Asset $asset)

Add an asset at the position that's defined in the asset.

Parameters

Asset $asset

protected addOutputAssetAt(Asset $item, string $position)

Add an asset at a specific position.

Parameters

Asset $item
string $position

Whether the asset should be loaded in the header or in the footer.

See also

AssetInterface::ASSET_POSITION_HEADER
AssetInterface::ASSET_POSITION_FOOTER

getAssetsToOutput()

Get a list of assets that need to be outputted.

Responsible for a number of things:

  1. Gets the required assets and adds them to the output assets array (which also contains other assets we have specifically asked for.)
  2. Returns the assets with the non-post-process-able assets FIRST, in the order in which they were added, with post-processable assets grouped after. We also make sure to maintain the proper position.

markAssetAsIncluded(string $assetType, string|false $assetHandle = false)

Notes in the current request that a particular asset has already been provided.

Parameters

string $assetType

E.g. 'css' or 'javascript'.

string|false $assetHandle

E.g. 'core/colorpicker'.

requireAsset(AssetGroup|Asset|string $assetType, string|false $assetHandle = false)

Adds a required asset to this request. This asset will attempt to be output or included when a view is rendered.

Parameters

AssetGroup|Asset|string $assetType
string|false $assetHandle

used when $assetType is a string, to form the group $assetType/$assetHandle to define a new AssetPointer instance

AssetGroup getRequiredAssets()

Returns all required assets.

Return Value

AssetGroup

protected bool filterProvidedAssets(Asset $asset)

No description

Parameters

Asset $asset

Return Value

bool

Asset[] getRequiredAssetsToOutput()

Returns only assets that are required but that aren't also in the providedAssetGroup.

Return Value

Asset[]