[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/WebAsset/ -> WebAssetManager.php (summary)

Joomla! Content Management System

Copyright: (C) 2019 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 997 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WebAssetManager:: (23 methods):
  __construct()
  getRegistry()
  reset()
  __call()
  useAsset()
  disableAsset()
  usePresetItems()
  disablePresetItems()
  getAssetState()
  isAssetActive()
  assetExists()
  registerAsset()
  getAsset()
  getAssets()
  getInlineRelation()
  filterOutInlineAssets()
  addInline()
  lock()
  getManagerState()
  enableDependencies()
  calculateOrderOfActiveAssets()
  getConnectionsGraph()
  getDependenciesForAsset()


Class: WebAssetManager  - X-Ref

Web Asset Manager class

__construct(WebAssetRegistry $registry)   X-Ref
Class constructor

param: WebAssetRegistry  $registry  The WebAsset Registry instance

getRegistry()   X-Ref
No description

reset()   X-Ref
Clears all collected items.

return: self

__call($method, $arguments)   X-Ref
Adds support for magic method calls

param: string  $method     A method name
param: array   $arguments  Arguments for a method
return: mixed

useAsset(string $type, string $name)   X-Ref
Enable an asset item to be attached to a Document

param: string  $type  The asset type, script or style
param: string  $name  The asset name
return: self

disableAsset(string $type, string $name)   X-Ref
Deactivate an asset item, so it will not be attached to a Document

param: string  $type  The asset type, script or style
param: string  $name  The asset name
return: self

usePresetItems($name)   X-Ref
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: string  $name  The asset name
return: self

disablePresetItems($name)   X-Ref
Deactivate list of assets provided by Preset item.

param: string  $name  The asset name
return: self

getAssetState(string $type, string $name)   X-Ref
Get a state for the Asset

param: string  $type  The asset type, script or style
param: string  $name  The asset name
return: integer

isAssetActive(string $type, string $name)   X-Ref
Check whether the asset are enabled

param: string  $type  The asset type, script or style
param: string  $name  The asset name
return: boolean

assetExists(string $type, string $name)   X-Ref
Helper method to check whether the asset exists in the registry.

param: string  $type  Asset type, script or style
param: string  $name  Asset name
return: boolean

registerAsset(string $type, $asset, string $uri = '', array $options = [], array $attributes = [], array $dependencies = [])   X-Ref
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: string               $type          The asset type, script or style
param: WebAssetItem|string  $asset         The asset name or instance to register
param: string               $uri           The URI for the asset
param: array                $options       Additional options for the asset
param: array                $attributes    Attributes for the asset
param: array                $dependencies  Asset dependencies
return: self

getAsset(string $type, string $name)   X-Ref
Helper method to get the asset from the registry.

param: string  $type  Asset type, script or style
param: string  $name  Asset name
return: WebAssetItemInterface

getAssets(string $type, bool $sort = false)   X-Ref
Get all active assets, optionally sort them to follow the dependency Graph

param: string  $type  The asset type, script or style
param: bool    $sort  Whether need to sort the assets to follow the dependency Graph
return: WebAssetItem[]

getInlineRelation(array $assets)   X-Ref
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: WebAssetItem[]  $assets  The assets list
return: array

filterOutInlineAssets(array &$assets)   X-Ref
Helper method to filter an inline assets

param: WebAssetItem[]  $assets  Reference to a full list of active assets
return: WebAssetItem[]  Array of inline assets

addInline(string $type, $content, array $options = [], array $attributes = [], array $dependencies = [])   X-Ref
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: string               $type          The asset type, script or style
param: WebAssetItem|string  $content       The content to of inline asset
param: array                $options       Additional options for the asset
param: array                $attributes    Attributes for the asset
param: array                $dependencies  Asset dependencies
return: self

lock()   X-Ref
Lock the manager to prevent further modifications

return: self

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

return: array

enableDependencies(string $type = null, WebAssetItem $asset = null)   X-Ref
Update Dependencies state for all active Assets or only for given

param: string        $type   The asset type, script or style
param: WebAssetItem  $asset  The asset instance to which need to enable dependencies
return: self

calculateOrderOfActiveAssets($type)   X-Ref
No description

getConnectionsGraph(array $assets)   X-Ref
No description

getDependenciesForAsset(string $type,WebAssetItem $asset,$recursively = false,string $recursionType = null,WebAssetItem $recursionRoot = null)   X-Ref
Return dependencies for Asset as array of WebAssetItem objects

param: string        $type           The asset type, script or style
param: WebAssetItem  $asset          Asset instance
param: boolean       $recursively    Whether to search for dependency recursively
param: string        $recursionType  The type of initial item to prevent loop
param: WebAssetItem  $recursionRoot  Initial item to prevent loop
return: array



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer