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 time the current asset was last modified. More...
 
 getIterator ()
 
 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...
 

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

Definition at line 35 of file GlobAsset.php.

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

36  {
37  $this->globs = (array) $globs;
38  $this->initialized = false;
39 
40  parent::__construct(array(), $filters, $root, $vars);
41  }
Create styles array
The data for the language used.

Member Function Documentation

◆ all()

Assetic\Asset\GlobAsset::all ( )

Returns all child assets.

Returns
array An array of AssetInterface objects

Implements Assetic\Asset\AssetCollectionInterface.

Definition at line 43 of file GlobAsset.php.

References Assetic\Asset\GlobAsset\initialize().

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
+ 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

Implements Assetic\Asset\AssetInterface.

Definition at line 61 of file GlobAsset.php.

References Assetic\Asset\GlobAsset\initialize().

62  {
63  if (!$this->initialized) {
64  $this->initialize();
65  }
66 
67  return parent::dump($additionalFilter);
68  }
initialize()
Initializes the collection based on the glob(s) passed in.
Definition: GlobAsset.php:97
+ Here is the call graph for this function:

◆ getIterator()

Assetic\Asset\GlobAsset::getIterator ( )

Definition at line 79 of file GlobAsset.php.

References Assetic\Asset\GlobAsset\initialize().

80  {
81  if (!$this->initialized) {
82  $this->initialize();
83  }
84 
85  return parent::getIterator();
86  }
initialize()
Initializes the collection based on the glob(s) passed in.
Definition: GlobAsset.php:97
+ Here is the call graph for this function:

◆ getLastModified()

Assetic\Asset\GlobAsset::getLastModified ( )

Returns the time the current asset was last modified.

Returns
integer|null A UNIX timestamp

Implements Assetic\Asset\AssetInterface.

Definition at line 70 of file GlobAsset.php.

References Assetic\Asset\GlobAsset\initialize().

71  {
72  if (!$this->initialized) {
73  $this->initialize();
74  }
75 
76  return parent::getLastModified();
77  }
initialize()
Initializes the collection based on the glob(s) passed in.
Definition: GlobAsset.php:97
+ 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.

References $path, Assetic\Asset\AssetCollection\add(), array, 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().

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
static resolve($template, array $vars, array $values)
Resolves variable placeholders.
Definition: VarUtils.php:32
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
add(AssetInterface $asset)
Adds an asset to the current collection.
Create styles array
The data for the language used.
getValues()
Returns the current values for this asset.
getVars()
Returns an array of variable names for this asset.
+ 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

Implements Assetic\Asset\AssetInterface.

Definition at line 52 of file GlobAsset.php.

References Assetic\Asset\GlobAsset\initialize().

53  {
54  if (!$this->initialized) {
55  $this->initialize();
56  }
57 
58  parent::load($additionalFilter);
59  }
initialize()
Initializes the collection based on the glob(s) passed in.
Definition: GlobAsset.php:97
+ 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

Implements Assetic\Asset\AssetInterface.

Definition at line 88 of file GlobAsset.php.

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

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: