![]() |
Joomla CMS
4.2.2
Documentation des API du CMS Joomla en version 4.2.2
|
Fonctions membres publiques | |
__construct (WebAssetRegistry $registry) | |
getRegistry () | |
reset () | |
__call ($method, $arguments) | |
useAsset (string $type, string $name) | |
disableAsset (string $type, string $name) | |
getAssetState (string $type, string $name) | |
isAssetActive (string $type, string $name) | |
assetExists (string $type, string $name) | |
registerAsset (string $type, $asset, string $uri='', array $options=[], array $attributes=[], array $dependencies=[]) | |
getAsset (string $type, string $name) | |
getAssets (string $type, bool $sort=false) | |
getInlineRelation (array $assets) | |
filterOutInlineAssets (array &$assets) | |
addInline (string $type, $content, array $options=[], array $attributes=[], array $dependencies=[]) | |
lock () | |
getManagerState () | |
Champs de données | |
const | ASSET_STATE_INACTIVE = 0 |
const | ASSET_STATE_ACTIVE = 1 |
const | ASSET_STATE_DEPENDENCY = 2 |
Fonctions membres protégées | |
usePresetItems ($name) | |
disablePresetItems ($name) | |
enableDependencies (string $type=null, WebAssetItem $asset=null) | |
calculateOrderOfActiveAssets ($type) | |
getConnectionsGraph (array $assets) | |
getDependenciesForAsset (string $type, WebAssetItem $asset, $recursively=false, string $recursionType=null, WebAssetItem $recursionRoot=null) | |
Attributs protégés | |
$registry | |
$activeAssets = [] | |
$locked = false | |
$dependenciesIsActual = false | |
Web Asset Manager class
WebAssetManager registerStyle(WebAssetItem|string $asset, string $uri = '', $options = [], $attributes = [], $dependencies = []) WebAssetManager registerAndUseStyle(WebAssetItem|string $asset, string $uri = '', $options = [], $attributes = [], $dependencies = []) WebAssetManager useStyle($name) WebAssetManager disableStyle($name) WebAssetManager addInlineStyle(WebAssetItem|string $content, $options = [], $attributes = [], $dependencies = [])
WebAssetManager registerScript(WebAssetItem|string $asset, string $uri = '', $options = [], $attributes = [], $dependencies = []) WebAssetManager registerAndUseScript(WebAssetItem|string $asset, string $uri = '', $options = [], $attributes = [], $dependencies = []) WebAssetManager useScript($name) WebAssetManager disableScript($name) WebAssetManager addInlineScript(WebAssetItem|string $content, $options = [], $attributes = [], $dependencies = [])
WebAssetManager registerPreset(WebAssetItem|string $asset, string $uri = '', $options = [], $attributes = [], $dependencies = []) WebAssetManager registerAndUsePreset(WebAssetItem|string $asset, string $uri = '', $options = [], $attributes = [], $dependencies = []) WebAssetManager usePreset($name) WebAssetManager disablePreset($name)
__construct | ( | WebAssetRegistry | $registry | ) |
Class constructor
WebAssetRegistry | $registry | The WebAsset Registry instance |
Références WebAssetRegistryAssetChanged\getAsset(), et WebAssetRegistryAssetChanged\getAssetType().
__call | ( | $method, | |
$arguments | |||
) |
Adds support for magic method calls
string | $method | A method name |
array | $arguments | Arguments for a method |
Références $method, $name, $this, $type, et WebAssetItemInterface\getName().
addInline | ( | string | $type, |
$content, | |||
array | $options = [] , |
||
array | $attributes = [] , |
||
array | $dependencies = [] |
||
) |
Add a new inline content asset. 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 ....)
string | $type | The asset type, script or style |
WebAssetItem | string | $content | The content to of inline asset |
array | $options | Additional options for the asset |
array | $attributes | Attributes for the asset |
array | $dependencies | Asset dependencies |
Références $attributes, $content, $name, $options, $this, $type, class, et elseif.
assetExists | ( | string | $type, |
string | $name | ||
) |
|
protected |
Calculate weight of active Assets, by its Dependencies
string | $type | The asset type, script or style |
disableAsset | ( | string | $type, |
string | $name | ||
) |
Deactivate an asset item, so it will not be attached to a Document
string | $type | The asset type, script or style |
string | $name | The asset name |
UnknownAssetException | When Asset cannot be found |
InvalidActionException | When the Manager already attached to a Document |
Implémente WebAssetManagerInterface.
|
protected |
|
protected |
Update Dependencies state for all active Assets or only for given
string | $type | The asset type, script or style |
WebAssetItem | $asset | The asset instance to which need to enable dependencies |
Références $name, $state, $this, $type, et WebAssetManager\ASSET_STATE_ACTIVE.
filterOutInlineAssets | ( | array & | $assets | ) |
Helper method to filter an inline assets
WebAssetItem[] | $assets Reference to a full list of active assets |
getAsset | ( | string | $type, |
string | $name | ||
) |
Helper method to get the asset from the registry.
string | $type | Asset type, script or style |
string | $name | Asset name |
UnknownAssetException | When Asset cannot be found |
getAssets | ( | string | $type, |
bool | $sort = false |
||
) |
Get all active assets, optionally sort them to follow the dependency Graph
string | $type | The asset type, script or style |
bool | $sort | Whether need to sort the assets to follow the dependency Graph |
UnknownAssetException | When Asset cannot be found |
UnsatisfiedDependencyException | When Dependency cannot be found |
Implémente WebAssetManagerInterface.
getAssetState | ( | string | $type, |
string | $name | ||
) |
|
protected |
Build Graph of Outgoing and Incoming connections for given assets.
WebAssetItem[] | $assets Asset instances |
Références $name.
|
protected |
Return dependencies for Asset as array of WebAssetItem objects
string | $type | The asset type, script or style |
WebAssetItem | $asset | Asset instance |
boolean | $recursively | Whether to search for dependency recursively |
string | $recursionType | The type of initial item to prevent loop |
WebAssetItem | $recursionRoot | Initial item to prevent loop |
UnsatisfiedDependencyException | When Dependency cannot be found |
Références $type.
getInlineRelation | ( | array | $assets | ) |
Helper method to calculate inline to non inline relation (before/after positions). 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
WebAssetItem[] | $assets The assets list |
getManagerState | ( | ) |
Get the manager state. A collection of registry files and active asset names (per type).
Références Joomla\CMS\HTML\getRegistry().
getRegistry | ( | ) |
isAssetActive | ( | string | $type, |
string | $name | ||
) |
Check whether the asset are enabled
string | $type | The asset type, script or style |
string | $name | The asset name |
UnknownAssetException | When Asset cannot be found |
Implémente WebAssetManagerInterface.
lock | ( | ) |
registerAsset | ( | string | $type, |
$asset, | |||
string | $uri = '' , |
||
array | $options = [] , |
||
array | $attributes = [] , |
||
array | $dependencies = [] |
||
) |
Register a new asset. 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 ....)
string | $type | The asset type, script or style |
WebAssetItem | string | $asset | The asset name or instance to register |
string | $uri | The URI for the asset |
array | $options | Additional options for the asset |
array | $attributes | Attributes for the asset |
array | $dependencies | Asset dependencies |
Références $attributes, $options, $this, $type, $uri, class, et elseif.
reset | ( | ) |
useAsset | ( | string | $type, |
string | $name | ||
) |
Enable an asset item to be attached to a Document
string | $type | The asset type, script or style |
string | $name | The asset name |
UnknownAssetException | When Asset cannot be found |
InvalidActionException | When the Manager already attached to a Document |
Implémente WebAssetManagerInterface.
|
protected |
Enable list of assets provided by Preset item.
"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.
string | $name | The asset name |
UnsatisfiedDependencyException | When Asset dependency cannot be found |
|
protected |
|
protected |
|
protected |
|
protected |
const ASSET_STATE_ACTIVE = 1 |
Référencé par WebAssetManager\enableDependencies().
const ASSET_STATE_DEPENDENCY = 2 |
const ASSET_STATE_INACTIVE = 0 |