ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Assetic\AssetManager Class Reference

Manages assets. More...

+ Inheritance diagram for Assetic\AssetManager:
+ Collaboration diagram for Assetic\AssetManager:

Public Member Functions

 get ($name)
 Gets an asset by name. More...
 
 has ($name)
 Checks if the current asset manager has a certain asset. More...
 
 set ($name, AssetInterface $asset)
 Registers an asset to the current asset manager. More...
 
 getNames ()
 Returns an array of asset names. More...
 
 clear ()
 Clears all assets. More...
 

Private Attributes

 $assets = array()
 

Detailed Description

Manages assets.

Author
Kris Wallsmith kris..nosp@m.wall.nosp@m.smith.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Definition at line 21 of file AssetManager.php.

Member Function Documentation

◆ clear()

Assetic\AssetManager::clear ( )

Clears all assets.

Definition at line 85 of file AssetManager.php.

86 {
87 $this->assets = array();
88 }

◆ get()

Assetic\AssetManager::get (   $name)

Gets an asset by name.

Parameters
string$nameThe asset name
Returns
AssetInterface The asset
Exceptions

InvalidArgumentException If there is no asset by that name

Reimplemented in Assetic\Factory\LazyAssetManager.

Definition at line 34 of file AssetManager.php.

35 {
36 if (!isset($this->assets[$name])) {
37 throw new \InvalidArgumentException(sprintf('There is no "%s" asset.', $name));
38 }
39
40 return $this->assets[$name];
41 }
sprintf('%.4f', $callTime)

References sprintf.

Referenced by Assetic\AssetWriter\writeManagerAssets().

+ Here is the caller graph for this function:

◆ getNames()

Assetic\AssetManager::getNames ( )

Returns an array of asset names.

Returns
array An array of asset names

Reimplemented in Assetic\Factory\LazyAssetManager.

Definition at line 77 of file AssetManager.php.

78 {
79 return array_keys($this->assets);
80 }

Referenced by Assetic\AssetWriter\writeManagerAssets().

+ Here is the caller graph for this function:

◆ has()

Assetic\AssetManager::has (   $name)

Checks if the current asset manager has a certain asset.

Parameters
string$namean asset name
Returns
Boolean True if the asset has been set, false if not

Reimplemented in Assetic\Factory\LazyAssetManager.

Definition at line 50 of file AssetManager.php.

51 {
52 return isset($this->assets[$name]);
53 }

◆ set()

Assetic\AssetManager::set (   $name,
AssetInterface  $asset 
)

Registers an asset to the current asset manager.

Parameters
string$nameThe asset name
AssetInterface$assetThe asset
Exceptions

InvalidArgumentException If the asset name is invalid

Definition at line 63 of file AssetManager.php.

64 {
65 if (!ctype_alnum(str_replace('_', '', $name))) {
66 throw new \InvalidArgumentException(sprintf('The name "%s" is invalid.', $name));
67 }
68
69 $this->assets[$name] = $asset;
70 }

References sprintf.

Field Documentation

◆ $assets

Assetic\AssetManager::$assets = array()
private

Definition at line 23 of file AssetManager.php.


The documentation for this class was generated from the following file: