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

A reference to an asset in the asset manager. More...

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

Public Member Functions

 __construct (AssetManager $am, $name)
 
 __clone ()
 
 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...
 
 getValues ()
 Returns the current values for this asset. More...
 
 setValues (array $values)
 Sets the values for the asset's variables. More...
 

Private Member Functions

 callAsset ($method, $arguments=array())
 
 flushFilters ()
 
 resolve ()
 

Private Attributes

 $am
 
 $name
 
 $filters = array()
 
 $clone = false
 
 $asset
 

Detailed Description

A reference to an asset in the asset manager.

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 AssetReference.php.

Constructor & Destructor Documentation

◆ __construct()

Assetic\Asset\AssetReference::__construct ( AssetManager  $am,
  $name 
)

Definition at line 30 of file AssetReference.php.

References Assetic\Asset\AssetReference\$am, and Assetic\Asset\AssetReference\$name.

31  {
32  $this->am = $am;
33  $this->name = $name;
34  }

Member Function Documentation

◆ __clone()

Assetic\Asset\AssetReference::__clone ( )

Definition at line 36 of file AssetReference.php.

References Assetic\Asset\AssetReference\$asset.

37  {
38  $this->clone = true;
39 
40  if ($this->asset) {
41  $this->asset = clone $this->asset;
42  }
43  }

◆ callAsset()

◆ clearFilters()

Assetic\Asset\AssetReference::clearFilters ( )

Clears all filters from the current asset.

Implements Assetic\Asset\AssetInterface.

Definition at line 57 of file AssetReference.php.

References array, and Assetic\Asset\AssetReference\callAsset().

58  {
59  $this->filters = array();
60  $this->callAsset(__FUNCTION__);
61  }
callAsset($method, $arguments=array())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ dump()

Assetic\Asset\AssetReference::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 70 of file AssetReference.php.

References array, Assetic\Asset\AssetReference\callAsset(), and Assetic\Asset\AssetReference\flushFilters().

71  {
72  $this->flushFilters();
73 
74  return $this->callAsset(__FUNCTION__, array($additionalFilter));
75  }
callAsset($method, $arguments=array())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ ensureFilter()

Assetic\Asset\AssetReference::ensureFilter ( FilterInterface  $filter)

Ensures the current asset includes the supplied filter.

Parameters
FilterInterface$filterA filter

Implements Assetic\Asset\AssetInterface.

Definition at line 45 of file AssetReference.php.

46  {
47  $this->filters[] = $filter;
48  }

◆ flushFilters()

Assetic\Asset\AssetReference::flushFilters ( )
private

Definition at line 141 of file AssetReference.php.

References Assetic\Asset\AssetReference\$asset, and Assetic\Asset\AssetReference\resolve().

Referenced by Assetic\Asset\AssetReference\dump(), Assetic\Asset\AssetReference\getFilters(), and Assetic\Asset\AssetReference\load().

142  {
143  $asset = $this->resolve();
144 
145  while ($filter = array_shift($this->filters)) {
146  $asset->ensureFilter($filter);
147  }
148  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContent()

Assetic\Asset\AssetReference::getContent ( )

Returns the loaded content of the current asset.

Returns
string The content

Implements Assetic\Asset\AssetInterface.

Definition at line 77 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

78  {
79  return $this->callAsset(__FUNCTION__);
80  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getFilters()

Assetic\Asset\AssetReference::getFilters ( )

Returns an array of filters currently applied.

Returns
array An array of filters

Implements Assetic\Asset\AssetInterface.

Definition at line 50 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset(), and Assetic\Asset\AssetReference\flushFilters().

51  {
52  $this->flushFilters();
53 
54  return $this->callAsset(__FUNCTION__);
55  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getLastModified()

Assetic\Asset\AssetReference::getLastModified ( )

Returns the time the current asset was last modified.

Returns
integer|null A UNIX timestamp

Implements Assetic\Asset\AssetInterface.

Definition at line 112 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

113  {
114  return $this->callAsset(__FUNCTION__);
115  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getSourceDirectory()

Assetic\Asset\AssetReference::getSourceDirectory ( )

Returns the asset's source directory.

The source directory is the directory the asset was located in and can be used to resolve references relative to an asset.

Returns
string|null The asset's source directory

Implements Assetic\Asset\AssetInterface.

Definition at line 97 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

98  {
99  return $this->callAsset(__FUNCTION__);
100  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getSourcePath()

Assetic\Asset\AssetReference::getSourcePath ( )

Returns the relative path for the source asset.

This value can be combined with the asset's source root (if both are non-null) to get something compatible with file_get_contents().

For example:

  • 'js/main.js'
  • 'main.js'
  • null
Returns
string|null The source asset path

Implements Assetic\Asset\AssetInterface.

Definition at line 92 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

93  {
94  return $this->callAsset(__FUNCTION__);
95  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getSourceRoot()

Assetic\Asset\AssetReference::getSourceRoot ( )

Returns an absolute path or URL to the source asset's root directory.

This value should be an absolute path to a directory in the filesystem, an absolute URL with no path, or null.

For example:

Returns
string|null The asset's root

Implements Assetic\Asset\AssetInterface.

Definition at line 87 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

88  {
89  return $this->callAsset(__FUNCTION__);
90  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getTargetPath()

Assetic\Asset\AssetReference::getTargetPath ( )

Returns the URL for the current asset.

Returns
string|null A web URL where the asset will be dumped

Implements Assetic\Asset\AssetInterface.

Definition at line 102 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

103  {
104  return $this->callAsset(__FUNCTION__);
105  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getValues()

Assetic\Asset\AssetReference::getValues ( )

Returns the current values for this asset.

Returns
array an array of strings

Implements Assetic\Asset\AssetInterface.

Definition at line 122 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

123  {
124  return $this->callAsset(__FUNCTION__);
125  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ getVars()

Assetic\Asset\AssetReference::getVars ( )

Returns an array of variable names for this asset.

Returns
array

Implements Assetic\Asset\AssetInterface.

Definition at line 117 of file AssetReference.php.

References Assetic\Asset\AssetReference\callAsset().

118  {
119  return $this->callAsset(__FUNCTION__);
120  }
callAsset($method, $arguments=array())
+ Here is the call graph for this function:

◆ load()

Assetic\Asset\AssetReference::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 63 of file AssetReference.php.

References array, Assetic\Asset\AssetReference\callAsset(), and Assetic\Asset\AssetReference\flushFilters().

64  {
65  $this->flushFilters();
66 
67  return $this->callAsset(__FUNCTION__, array($additionalFilter));
68  }
callAsset($method, $arguments=array())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ resolve()

Assetic\Asset\AssetReference::resolve ( )
private

Definition at line 150 of file AssetReference.php.

References Assetic\Asset\AssetReference\$asset.

Referenced by Assetic\Asset\AssetReference\callAsset(), and Assetic\Asset\AssetReference\flushFilters().

151  {
152  if ($this->asset) {
153  return $this->asset;
154  }
155 
156  $asset = $this->am->get($this->name);
157 
158  if ($this->clone) {
159  $asset = $this->asset = clone $asset;
160  }
161 
162  return $asset;
163  }
+ Here is the caller graph for this function:

◆ setContent()

Assetic\Asset\AssetReference::setContent (   $content)

Sets the content of the current asset.

Filters can use this method to change the content of the asset.

Parameters
string$contentThe asset content

Implements Assetic\Asset\AssetInterface.

Definition at line 82 of file AssetReference.php.

References array, and Assetic\Asset\AssetReference\callAsset().

83  {
84  $this->callAsset(__FUNCTION__, array($content));
85  }
callAsset($method, $arguments=array())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ setTargetPath()

Assetic\Asset\AssetReference::setTargetPath (   $targetPath)

Sets the URL for the current asset.

Parameters
string$targetPathA web URL where the asset will be dumped

Implements Assetic\Asset\AssetInterface.

Definition at line 107 of file AssetReference.php.

References array, and Assetic\Asset\AssetReference\callAsset().

108  {
109  $this->callAsset(__FUNCTION__, array($targetPath));
110  }
callAsset($method, $arguments=array())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ setValues()

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

Sets the values for the asset's variables.

Parameters
array$values

Implements Assetic\Asset\AssetInterface.

Definition at line 127 of file AssetReference.php.

References array, and Assetic\Asset\AssetReference\callAsset().

128  {
129  $this->callAsset(__FUNCTION__, array($values));
130  }
callAsset($method, $arguments=array())
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $am

Assetic\Asset\AssetReference::$am
private

Definition at line 24 of file AssetReference.php.

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

◆ $asset

◆ $clone

Assetic\Asset\AssetReference::$clone = false
private

Definition at line 27 of file AssetReference.php.

◆ $filters

Assetic\Asset\AssetReference::$filters = array()
private

Definition at line 26 of file AssetReference.php.

◆ $name

Assetic\Asset\AssetReference::$name
private

Definition at line 25 of file AssetReference.php.

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


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