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

A collection of assets loaded by glob. More...

+ Inheritance diagram for Assetic\Asset\GlobAsset:
+ Collaboration diagram for Assetic\Asset\GlobAsset:

Public Member Functions

 __construct ($globs, $filters=array(), $root=null, array $vars=array())
 Constructor. More...
 
 all ()
 Returns all child assets. More...
 
 load (FilterInterface $additionalFilter=null)
 Loads the asset into memory and applies load filters. More...
 
 dump (FilterInterface $additionalFilter=null)
 Applies dump filters and returns the asset as a string. More...
 
 getLastModified ()
 Returns the highest last-modified value of all assets in the current collection. More...
 
 getIterator ()
 Returns an iterator for looping recursively over unique leaves. More...
 
 setValues (array $values)
 Sets the values for the asset's variables. More...
 
- Public Member Functions inherited from Assetic\Asset\AssetCollection
 __construct ($assets=array(), $filters=array(), $sourceRoot=null, array $vars=array())
 Constructor. More...
 
 __clone ()
 
 all ()
 Returns all child assets. More...
 
 add (AssetInterface $asset)
 Adds an asset to the current collection. More...
 
 removeLeaf (AssetInterface $needle, $graceful=false)
 Removes a leaf. More...
 
 replaceLeaf (AssetInterface $needle, AssetInterface $replacement, $graceful=false)
 Replaces an existing leaf with a new one. More...
 
 ensureFilter (FilterInterface $filter)
 Ensures the current asset includes the supplied filter. More...
 
 getFilters ()
 Returns an array of filters currently applied. More...
 
 clearFilters ()
 Clears all filters from the current asset. More...
 
 load (FilterInterface $additionalFilter=null)
 Loads the asset into memory and applies load filters. More...
 
 dump (FilterInterface $additionalFilter=null)
 Applies dump filters and returns the asset as a string. More...
 
 getContent ()
 Returns the loaded content of the current asset. More...
 
 setContent ($content)
 Sets the content of the current asset. More...
 
 getSourceRoot ()
 Returns an absolute path or URL to the source asset's root directory. More...
 
 getSourcePath ()
 Returns the relative path for the source asset. More...
 
 getSourceDirectory ()
 Returns the asset's source directory. More...
 
 getTargetPath ()
 Returns the URL for the current asset. More...
 
 setTargetPath ($targetPath)
 Sets the URL for the current asset. More...
 
 getLastModified ()
 Returns the highest last-modified value of all assets in the current collection. More...
 
 getIterator ()
 Returns an iterator for looping recursively over unique leaves. More...
 
 getVars ()
 Returns an array of variable names for this asset. More...
 
 setValues (array $values)
 Sets the values for the asset's variables. More...
 
 getValues ()
 Returns the current values for this asset. More...
 
 all ()
 Returns all child assets. More...
 
 add (AssetInterface $asset)
 Adds an asset to the current collection. More...
 
 removeLeaf (AssetInterface $leaf, $graceful=false)
 Removes a leaf. More...
 
 replaceLeaf (AssetInterface $needle, AssetInterface $replacement, $graceful=false)
 Replaces an existing leaf with a new one. More...
 
 ensureFilter (FilterInterface $filter)
 Ensures the current asset includes the supplied filter. More...
 
 getFilters ()
 Returns an array of filters currently applied. More...
 
 clearFilters ()
 Clears all filters from the current asset. More...
 
 load (FilterInterface $additionalFilter=null)
 Loads the asset into memory and applies load filters. More...
 
 dump (FilterInterface $additionalFilter=null)
 Applies dump filters and returns the asset as a string. More...
 
 getContent ()
 Returns the loaded content of the current asset. More...
 
 setContent ($content)
 Sets the content of the current asset. More...
 
 getSourceRoot ()
 Returns an absolute path or URL to the source asset's root directory. More...
 
 getSourcePath ()
 Returns the relative path for the source asset. More...
 
 getSourceDirectory ()
 Returns the asset's source directory. More...
 
 getTargetPath ()
 Returns the URL for the current asset. More...
 
 setTargetPath ($targetPath)
 Sets the URL for the current asset. More...
 
 getLastModified ()
 Returns the time the current asset was last modified. More...
 
 getVars ()
 Returns an array of variable names for this asset. More...
 
 setValues (array $values)
 Sets the values for the asset's variables. More...
 
 getValues ()
 Returns the current values for this asset. More...
 

Private Member Functions

 initialize ()
 Initializes the collection based on the glob(s) passed in. More...
 

Private Attributes

 $globs
 
 $initialized
 

Detailed Description

A collection of assets loaded by glob.

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

Definition at line 22 of file GlobAsset.php.

Constructor & Destructor Documentation

◆ __construct()

Assetic\Asset\GlobAsset::__construct (   $globs,
  $filters = array(),
  $root = null,
array  $vars = array() 
)

Constructor.

Parameters
string | array$globsA single glob path or array of paths
array$filtersAn array of filters
string$rootThe root directory
array$vars

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 35 of file GlobAsset.php.

36 {
37 $this->globs = (array) $globs;
38 $this->initialized = false;
39
40 parent::__construct(array(), $filters, $root, $vars);
41 }

References Assetic\Asset\AssetCollection\$filters, Assetic\Asset\GlobAsset\$globs, and Assetic\Asset\AssetCollection\$vars.

Member Function Documentation

◆ all()

Assetic\Asset\GlobAsset::all ( )

Returns all child assets.

Returns
array An array of AssetInterface objects

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 43 of file GlobAsset.php.

44 {
45 if (!$this->initialized) {
46 $this->initialize();
47 }
48
49 return parent::all();
50 }
initialize()
Initializes the collection based on the glob(s) passed in.
Definition: GlobAsset.php:97

References Assetic\Asset\GlobAsset\initialize().

+ Here is the call graph for this function:

◆ dump()

Assetic\Asset\GlobAsset::dump ( FilterInterface  $additionalFilter = null)

Applies dump filters and returns the asset as a string.

You may provide an additional filter to apply during dump.

Dumping an asset should not change its state.

If the current asset has not been loaded yet, it should be automatically loaded at this time.

Parameters
FilterInterface$additionalFilterAn additional filter
Returns
string The filtered content of the current asset

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 61 of file GlobAsset.php.

62 {
63 if (!$this->initialized) {
64 $this->initialize();
65 }
66
67 return parent::dump($additionalFilter);
68 }

References Assetic\Asset\GlobAsset\initialize().

+ Here is the call graph for this function:

◆ getIterator()

Assetic\Asset\GlobAsset::getIterator ( )

Returns an iterator for looping recursively over unique leaves.

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 79 of file GlobAsset.php.

80 {
81 if (!$this->initialized) {
82 $this->initialize();
83 }
84
85 return parent::getIterator();
86 }

References Assetic\Asset\GlobAsset\initialize().

+ Here is the call graph for this function:

◆ getLastModified()

Assetic\Asset\GlobAsset::getLastModified ( )

Returns the highest last-modified value of all assets in the current collection.

Returns
integer|null A UNIX timestamp

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 70 of file GlobAsset.php.

71 {
72 if (!$this->initialized) {
73 $this->initialize();
74 }
75
76 return parent::getLastModified();
77 }

References Assetic\Asset\GlobAsset\initialize().

+ Here is the call graph for this function:

◆ initialize()

Assetic\Asset\GlobAsset::initialize ( )
private

Initializes the collection based on the glob(s) passed in.

Definition at line 97 of file GlobAsset.php.

98 {
99 foreach ($this->globs as $glob) {
100 $glob = VarUtils::resolve($glob, $this->getVars(), $this->getValues());
101
102 if (false !== $paths = glob($glob)) {
103 foreach ($paths as $path) {
104 if (is_file($path)) {
105 $asset = new FileAsset($path, array(), $this->getSourceRoot(), null, $this->getVars());
106 $asset->setValues($this->getValues());
107 $this->add($asset);
108 }
109 }
110 }
111 }
112
113 $this->initialized = true;
114 }
$path
Definition: aliased.php:25
getVars()
Returns an array of variable names for this asset.
add(AssetInterface $asset)
Adds an asset to the current collection.
getValues()
Returns the current values for this asset.
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
static resolve($template, array $vars, array $values)
Resolves variable placeholders.
Definition: VarUtils.php:32

References $path, Assetic\Asset\AssetCollection\add(), Assetic\Asset\AssetCollection\getSourceRoot(), Assetic\Asset\AssetCollection\getValues(), Assetic\Asset\AssetCollection\getVars(), and Assetic\Util\VarUtils\resolve().

Referenced by Assetic\Asset\GlobAsset\all(), Assetic\Asset\GlobAsset\dump(), Assetic\Asset\GlobAsset\getIterator(), Assetic\Asset\GlobAsset\getLastModified(), and Assetic\Asset\GlobAsset\load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

Assetic\Asset\GlobAsset::load ( FilterInterface  $additionalFilter = null)

Loads the asset into memory and applies load filters.

You may provide an additional filter to apply during load.

Parameters
FilterInterface$additionalFilterAn additional filter

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 52 of file GlobAsset.php.

53 {
54 if (!$this->initialized) {
55 $this->initialize();
56 }
57
58 parent::load($additionalFilter);
59 }

References Assetic\Asset\GlobAsset\initialize().

+ Here is the call graph for this function:

◆ setValues()

Assetic\Asset\GlobAsset::setValues ( array  $values)

Sets the values for the asset's variables.

Parameters
array$values

Reimplemented from Assetic\Asset\AssetCollection.

Definition at line 88 of file GlobAsset.php.

89 {
90 parent::setValues($values);
91 $this->initialized = false;
92 }

References Assetic\Asset\AssetCollection\$values.

Field Documentation

◆ $globs

Assetic\Asset\GlobAsset::$globs
private

Definition at line 24 of file GlobAsset.php.

Referenced by Assetic\Asset\GlobAsset\__construct().

◆ $initialized

Assetic\Asset\GlobAsset::$initialized
private

Definition at line 25 of file GlobAsset.php.


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