Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe WebAssetManager
+ Graphe d'héritage de WebAssetManager:

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
 

Description détaillée

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)

Depuis
4.0.0

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( WebAssetRegistry  $registry)

Class constructor

Paramètres
WebAssetRegistry$registryThe WebAsset Registry instance
Depuis
4.0.0

Références WebAssetRegistryAssetChanged\getAsset(), et WebAssetRegistryAssetChanged\getAssetType().

Documentation des fonctions membres

◆ __call()

__call (   $method,
  $arguments 
)

Adds support for magic method calls

Paramètres
string$methodA method name
array$argumentsArguments for a method
Renvoie
mixed
Exceptions

Références $method, $name, $this, $type, et WebAssetItemInterface\getName().

◆ addInline()

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

Paramètres
string$typeThe asset type, script or style
WebAssetItem | string$contentThe content to of inline asset
array$optionsAdditional options for the asset
array$attributesAttributes for the asset
array$dependenciesAsset dependencies
Renvoie
self
Depuis
4.0.0
Exceptions

Références $attributes, $content, $name, $options, $this, $type, class, et elseif.

◆ assetExists()

assetExists ( string  $type,
string  $name 
)

Helper method to check whether the asset exists in the registry.

Paramètres
string$typeAsset type, script or style
string$nameAsset name
Renvoie
boolean
Depuis
4.0.0

Références $name, et $type.

◆ calculateOrderOfActiveAssets()

calculateOrderOfActiveAssets (   $type)
protected

Calculate weight of active Assets, by its Dependencies

Paramètres
string$typeThe asset type, script or style
Renvoie
WebAssetItem[]
Depuis
4.0.0

Références $item, $name, $type, et null.

◆ disableAsset()

disableAsset ( string  $type,
string  $name 
)

Deactivate an asset item, so it will not be attached to a Document

Paramètres
string$typeThe asset type, script or style
string$nameThe asset name
Renvoie
self
Exceptions
UnknownAssetExceptionWhen Asset cannot be found
InvalidActionExceptionWhen the Manager already attached to a Document
Depuis
4.0.0

Implémente WebAssetManagerInterface.

Références $name, $this, et $type.

◆ disablePresetItems()

disablePresetItems (   $name)
protected

Deactivate list of assets provided by Preset item.

Paramètres
string$nameThe asset name
Renvoie
self
Exceptions
UnsatisfiedDependencyExceptionWhen Asset dependency cannot be found
Depuis
4.0.0

Références $name, et $this.

◆ enableDependencies()

enableDependencies ( string  $type = null,
WebAssetItem  $asset = null 
)
protected

Update Dependencies state for all active Assets or only for given

Paramètres
string$typeThe asset type, script or style
WebAssetItem$assetThe asset instance to which need to enable dependencies
Renvoie
self
Depuis
4.0.0

Références $name, $state, $this, $type, et WebAssetManager\ASSET_STATE_ACTIVE.

◆ filterOutInlineAssets()

filterOutInlineAssets ( array &  $assets)

Helper method to filter an inline assets

Paramètres
WebAssetItem[]$assets Reference to a full list of active assets
Renvoie
WebAssetItem[] Array of inline assets
Depuis
4.0.0

◆ getAsset()

getAsset ( string  $type,
string  $name 
)

Helper method to get the asset from the registry.

Paramètres
string$typeAsset type, script or style
string$nameAsset name
Renvoie
WebAssetItemInterface
Exceptions
UnknownAssetExceptionWhen Asset cannot be found
Depuis
4.0.0

Références $name, et $type.

◆ getAssets()

getAssets ( string  $type,
bool  $sort = false 
)

Get all active assets, optionally sort them to follow the dependency Graph

Paramètres
string$typeThe asset type, script or style
bool$sortWhether need to sort the assets to follow the dependency Graph
Renvoie
WebAssetItem[]
Exceptions
UnknownAssetExceptionWhen Asset cannot be found
UnsatisfiedDependencyExceptionWhen Dependency cannot be found
Depuis
4.0.0

Implémente WebAssetManagerInterface.

Références $name, $sort, et $type.

◆ getAssetState()

getAssetState ( string  $type,
string  $name 
)

Get a state for the Asset

Paramètres
string$typeThe asset type, script or style
string$nameThe asset name
Renvoie
integer
Exceptions
UnknownAssetExceptionWhen Asset cannot be found
Depuis
4.0.0

Références $name, et $type.

◆ getConnectionsGraph()

getConnectionsGraph ( array  $assets)
protected

Build Graph of Outgoing and Incoming connections for given assets.

Paramètres
WebAssetItem[]$assets Asset instances
Renvoie
array
Depuis
4.0.0

Références $name.

◆ getDependenciesForAsset()

getDependenciesForAsset ( string  $type,
WebAssetItem  $asset,
  $recursively = false,
string  $recursionType = null,
WebAssetItem  $recursionRoot = null 
)
protected

Return dependencies for Asset as array of WebAssetItem objects

Paramètres
string$typeThe asset type, script or style
WebAssetItem$assetAsset instance
boolean$recursivelyWhether to search for dependency recursively
string$recursionTypeThe type of initial item to prevent loop
WebAssetItem$recursionRootInitial item to prevent loop
Renvoie
array
Exceptions
UnsatisfiedDependencyExceptionWhen Dependency cannot be found
Depuis
4.0.0

Références $type.

◆ getInlineRelation()

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

Paramètres
WebAssetItem[]$assets The assets list
Renvoie
array
Depuis
4.0.0

Références $position, et null.

◆ getManagerState()

getManagerState ( )

Get the manager state. A collection of registry files and active asset names (per type).

Renvoie
array
Depuis
4.0.0

Références Joomla\CMS\HTML\getRegistry().

◆ getRegistry()

getRegistry ( )

Get associated registry instance

Renvoie
WebAssetRegistry
Depuis
4.0.0

◆ isAssetActive()

isAssetActive ( string  $type,
string  $name 
)

Check whether the asset are enabled

Paramètres
string$typeThe asset type, script or style
string$nameThe asset name
Renvoie
boolean
Exceptions
UnknownAssetExceptionWhen Asset cannot be found
Depuis
4.0.0

Implémente WebAssetManagerInterface.

Références $name, et $type.

◆ lock()

lock ( )

Lock the manager to prevent further modifications

Renvoie
self
Depuis
4.0.0

Références $this.

◆ registerAsset()

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

Paramètres
string$typeThe asset type, script or style
WebAssetItem | string$assetThe asset name or instance to register
string$uriThe URI for the asset
array$optionsAdditional options for the asset
array$attributesAttributes for the asset
array$dependenciesAsset dependencies
Renvoie
self
Depuis
4.0.0
Exceptions

Références $attributes, $options, $this, $type, $uri, class, et elseif.

◆ reset()

reset ( )

Clears all collected items.

Renvoie
self
Depuis
4.1.1

Références $this.

◆ useAsset()

useAsset ( string  $type,
string  $name 
)

Enable an asset item to be attached to a Document

Paramètres
string$typeThe asset type, script or style
string$nameThe asset name
Renvoie
self
Exceptions
UnknownAssetExceptionWhen Asset cannot be found
InvalidActionExceptionWhen the Manager already attached to a Document
Depuis
4.0.0

Implémente WebAssetManagerInterface.

Références $name, $this, et $type.

◆ usePresetItems()

usePresetItems (   $name)
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.

Paramètres
string$nameThe asset name
Renvoie
self
Exceptions
UnsatisfiedDependencyExceptionWhen Asset dependency cannot be found
Depuis
4.0.0

Références $name, et $this.

Documentation des champs

◆ $activeAssets

$activeAssets = []
protected

◆ $dependenciesIsActual

$dependenciesIsActual = false
protected

◆ $locked

$locked = false
protected

◆ $registry

$registry
protected

◆ ASSET_STATE_ACTIVE

const ASSET_STATE_ACTIVE = 1

◆ ASSET_STATE_DEPENDENCY

const ASSET_STATE_DEPENDENCY = 2

◆ ASSET_STATE_INACTIVE

const ASSET_STATE_INACTIVE = 0

La documentation de cette classe a été générée à partir du fichier suivant :