WebAssetManager
Implements WebAssetManagerInterfaceWeb Asset Manager class
since |
4.0.0 |
---|---|
package |
Joomla CMS |
Methods
__call
Adds support for magic method calls
__call(string method, array arguments) : mixed
throws |
|
---|---|
since |
4.0.0 |
Arguments
- method
string
A method name- arguments
array
Arguments for a method
Response
mixed
__construct
Class constructor
__construct(\Joomla\CMS\WebAsset\WebAssetRegistry registry) : mixed
since |
4.0.0 |
---|
Arguments
- registry
\Joomla\CMS\WebAsset\WebAssetRegistry
The WebAsset Registry instance
Response
mixed
addInline
Add a new inline content asset.
addInline(string type, \Joomla\CMS\WebAsset\WebAssetItem|string content, array options = [], array attributes = [], array dependencies = []) : self
Allow to register WebAssetItem instance in the registry, by call addInline($type, $assetInstance) Or create an asset on fly (from name and Uri) and register in the registry, by call addInline($type, $content, $options ....)
since |
4.0.0 |
---|---|
throws |
|
Arguments
- type
string
The asset type, script or style- content
\Joomla\CMS\WebAsset\WebAssetItem|string
The content to of inline asset- options
array
Additional options for the asset- attributes
array
Attributes for the asset- dependencies
array
Asset dependencies
Response
self
addInlineScript
addInlineScript(\Joomla\CMS\WebAsset\WebAssetItem|string content, mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- content
\Joomla\CMS\WebAsset\WebAssetItem|string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
addInlineStyle
addInlineStyle(\Joomla\CMS\WebAsset\WebAssetItem|string content, mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- content
\Joomla\CMS\WebAsset\WebAssetItem|string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
assetExists
Helper method to check whether the asset exists in the registry.
assetExists(string type, string name) : bool
since |
4.0.0 |
---|
Arguments
- type
string
Asset type, script or style- name
string
Asset name
Response
bool
calculateOrderOfActiveAssets
Calculate weight of active Assets, by its Dependencies
calculateOrderOfActiveAssets(string type) : \Joomla\CMS\WebAsset\WebAssetItem[]
since |
4.0.0 |
---|
Arguments
- type
string
The asset type, script or style
Response
\Joomla\CMS\WebAsset\WebAssetItem[]
disableAsset
Deactivate an asset item, so it will not be attached to a Document
disableAsset(string type, string name) : self
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
The asset type, script or style- name
string
The asset name
Response
self
disablePreset
disablePreset(mixed name) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- name
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
disablePresetItems
Deactivate list of assets provided by Preset item.
disablePresetItems(string name) : self
throws |
|
---|---|
since |
4.0.0 |
Arguments
- name
string
The asset name
Response
self
disableScript
disableScript(mixed name) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- name
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
disableStyle
disableStyle(mixed name) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- name
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
enableDependencies
Update Dependencies state for all active Assets or only for given
enableDependencies(string type = null, \Joomla\CMS\WebAsset\WebAssetItem asset = null) : self
since |
4.0.0 |
---|
Arguments
- type
string
The asset type, script or style- asset
\Joomla\CMS\WebAsset\WebAssetItem
The asset instance to which need to enable dependencies
Response
self
filterOutInlineAssets
Helper method to filter an inline assets
filterOutInlineAssets(\Joomla\CMS\WebAsset\WebAssetItem[] &assets) : \Joomla\CMS\WebAsset\WebAssetItem[]
since |
4.0.0 |
---|
Arguments
- assets
\Joomla\CMS\WebAsset\WebAssetItem[]
Reference to a full list of active assets
Response
\Joomla\CMS\WebAsset\WebAssetItem[]
Array of inline assets
getAsset
Helper method to get the asset from the registry.
getAsset(string type, string name) : \Joomla\CMS\WebAsset\WebAssetItemInterface
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
Asset type, script or style- name
string
Asset name
Response
\Joomla\CMS\WebAsset\WebAssetItemInterface
getAssets
Get all active assets, optionally sort them to follow the dependency Graph
getAssets(string type, bool sort = false) : \Joomla\CMS\WebAsset\WebAssetItem[]
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
The asset type, script or style- sort
bool
Whether need to sort the assets to follow the dependency Graph
Response
\Joomla\CMS\WebAsset\WebAssetItem[]
getAssetState
Get a state for the Asset
getAssetState(string type, string name) : int
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
The asset type, script or style- name
string
The asset name
Response
int
getConnectionsGraph
Build Graph of Outgoing and Incoming connections for given assets.
getConnectionsGraph(\Joomla\CMS\WebAsset\WebAssetItem[] assets) : array
since |
4.0.0 |
---|
Arguments
- assets
\Joomla\CMS\WebAsset\WebAssetItem[]
Asset instances
Response
array
getDependenciesForAsset
Return dependencies for Asset as array of WebAssetItem objects
getDependenciesForAsset(string type, \Joomla\CMS\WebAsset\WebAssetItem asset, bool recursively = false, string recursionType = null, \Joomla\CMS\WebAsset\WebAssetItem recursionRoot = null) : array
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
The asset type, script or style- asset
\Joomla\CMS\WebAsset\WebAssetItem
Asset instance- recursively
bool
Whether to search for dependency recursively- recursionType
string
The type of initial item to prevent loop- recursionRoot
\Joomla\CMS\WebAsset\WebAssetItem
Initial item to prevent loop
Response
array
getInlineRelation
Helper method to calculate inline to non inline relation (before/after positions).
getInlineRelation(\Joomla\CMS\WebAsset\WebAssetItem[] assets) : array
Return associated array, which contain dependency (handle) name as key, and list of inline items for each position. Example: ['handle.name' => ['before' => ['inline1', 'inline2'], 'after' => ['inline3', 'inline4']]]
Note: If inline asset have a multiple dependencies, then will be used last one from the list for positioning
since |
4.0.0 |
---|
Arguments
- assets
\Joomla\CMS\WebAsset\WebAssetItem[]
The assets list
Response
array
getManagerState
Get the manager state. A collection of registry files and active asset names (per type).
getManagerState() : array
since |
4.0.0 |
---|
Response
array
getRegistry
Get associated registry instance
getRegistry() : \Joomla\CMS\WebAsset\WebAssetRegistry
since |
4.0.0 |
---|
Response
\Joomla\CMS\WebAsset\WebAssetRegistry
isAssetActive
Check whether the asset are enabled
isAssetActive(string type, string name) : bool
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
The asset type, script or style- name
string
The asset name
Response
bool
lock
Lock the manager to prevent further modifications
lock() : self
since |
4.0.0 |
---|
Response
self
registerAndUsePreset
registerAndUsePreset(\Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
- uri = ''
string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
registerAndUseScript
registerAndUseScript(\Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
- uri = ''
string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
registerAndUseStyle
registerAndUseStyle(\Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
- uri = ''
string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
registerAsset
Register a new asset.
registerAsset(string type, \Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', array options = [], array attributes = [], array dependencies = []) : self
Allow to register WebAssetItem instance in the registry, by call registerAsset($type, $assetInstance) Or create an asset on fly (from name and Uri) and register in the registry, by call registerAsset($type, $assetName, $uri, $options ....)
since |
4.0.0 |
---|---|
throws |
|
Arguments
- type
string
The asset type, script or style- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
The asset name or instance to register- uri
string
The URI for the asset- options
array
Additional options for the asset- attributes
array
Attributes for the asset- dependencies
array
Asset dependencies
Response
self
registerPreset
registerPreset(\Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
- uri = ''
string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
registerScript
registerScript(\Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
- uri = ''
string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
registerStyle
registerStyle(\Joomla\CMS\WebAsset\WebAssetItem|string asset, string uri = '', mixed options, mixed attributes, mixed dependencies) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- asset
\Joomla\CMS\WebAsset\WebAssetItem|string
- uri = ''
string
- options
mixed
- attributes
mixed
- dependencies
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
reset
Clears all collected items.
reset() : self
since |
4.1.1 |
---|
Response
self
useAsset
Enable an asset item to be attached to a Document
useAsset(string type, string name) : self
throws |
|
---|---|
since |
4.0.0 |
Arguments
- type
string
The asset type, script or style- name
string
The asset name
Response
self
usePreset
usePreset(mixed name) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- name
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
usePresetItems
Enable list of assets provided by Preset item.
usePresetItems(string name) : self
"Preset" a special kind of asset that hold a list of assets that has to be enabled, same as direct call of useAsset() to each of item in list. Can hold mixed types of assets (script, style, another preset, etc), the type provided after # symbol, after the asset name, example: foo#style, bar#script.
The method call useAsset() internally for each of its dependency, this is important for keeping FIFO order of enabled items. The Preset not a strict asset, and each of its dependency can be safely disabled by use of disableAsset() later.
throws |
|
---|---|
since |
4.0.0 |
Arguments
- name
string
The asset name
Response
self
useScript
useScript(mixed name) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- name
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
useStyle
useStyle(mixed name) : \Joomla\CMS\WebAsset\WebAssetManager
Arguments
- name
mixed
Response
\Joomla\CMS\WebAsset\WebAssetManager
Constants
ASSET_STATE_INACTIVE
Mark inactive asset
Value | 0 |
---|---|
since |
4.0.0 |
Type(s)
int
ASSET_STATE_ACTIVE
Mark active asset. Just enabled, but WITHOUT dependency resolved
Value | 1 |
---|---|
since |
4.0.0 |
Type(s)
int
ASSET_STATE_DEPENDENCY
Mark active asset that is enabled as dependency to another asset
Value | 2 |
---|---|
since |
4.0.0 |
Type(s)
int
Properties
registry
The WebAsset Registry instance
since |
4.0.0 |
---|
Type(s)
\Joomla\CMS\WebAsset\WebAssetRegistry
activeAssets
A list of active assets (including their dependencies).
Array of Name => State
since |
4.0.0 |
---|
Type(s)
array
locked
Internal marker to check the manager state, to prevent use of the manager after an assets are rendered
since |
4.0.0 |
---|
Type(s)
bool
dependenciesIsActual
Internal marker to keep track when need to recheck dependencies
since |
4.0.0 |
---|
Type(s)
bool