ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GlobAsset.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of the Assetic package, an OpenSky project.
5 *
6 * (c) 2010-2014 OpenSky Project Inc
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Assetic\Asset;
13
16
23{
24 private $globs;
25 private $initialized;
26
35 public function __construct($globs, $filters = array(), $root = null, array $vars = array())
36 {
37 $this->globs = (array) $globs;
38 $this->initialized = false;
39
40 parent::__construct(array(), $filters, $root, $vars);
41 }
42
43 public function all()
44 {
45 if (!$this->initialized) {
46 $this->initialize();
47 }
48
49 return parent::all();
50 }
51
52 public function load(FilterInterface $additionalFilter = null)
53 {
54 if (!$this->initialized) {
55 $this->initialize();
56 }
57
58 parent::load($additionalFilter);
59 }
60
61 public function dump(FilterInterface $additionalFilter = null)
62 {
63 if (!$this->initialized) {
64 $this->initialize();
65 }
66
67 return parent::dump($additionalFilter);
68 }
69
70 public function getLastModified()
71 {
72 if (!$this->initialized) {
73 $this->initialize();
74 }
75
76 return parent::getLastModified();
77 }
78
79 public function getIterator()
80 {
81 if (!$this->initialized) {
82 $this->initialize();
83 }
84
85 return parent::getIterator();
86 }
87
88 public function setValues(array $values)
89 {
90 parent::setValues($values);
91 $this->initialized = false;
92 }
93
97 private function initialize()
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 }
115}
$path
Definition: aliased.php:25
A collection of assets.
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.
Represents an asset loaded from a file.
Definition: FileAsset.php:23
A collection of assets loaded by glob.
Definition: GlobAsset.php:23
__construct($globs, $filters=array(), $root=null, array $vars=array())
Constructor.
Definition: GlobAsset.php:35
dump(FilterInterface $additionalFilter=null)
Applies dump filters and returns the asset as a string.
Definition: GlobAsset.php:61
getIterator()
Returns an iterator for looping recursively over unique leaves.
Definition: GlobAsset.php:79
initialize()
Initializes the collection based on the glob(s) passed in.
Definition: GlobAsset.php:97
load(FilterInterface $additionalFilter=null)
Loads the asset into memory and applies load filters.
Definition: GlobAsset.php:52
all()
Returns all child assets.
Definition: GlobAsset.php:43
setValues(array $values)
Sets the values for the asset's variables.
Definition: GlobAsset.php:88
getLastModified()
Returns the highest last-modified value of all assets in the current collection.
Definition: GlobAsset.php:70
Variable utilities.
Definition: VarUtils.php:20
static resolve($template, array $vars, array $values)
Resolves variable placeholders.
Definition: VarUtils.php:32
An exception for terminatinating execution or to throw for unit testing.
A filter manipulates an asset at load and dump.