45 $this->assets =
array();
52 $this->clones = new \SplObjectStorage();
54 $this->values =
array();
60 $this->clones = new \SplObjectStorage();
70 $this->assets[] = $asset;
75 foreach ($this->assets as $i => $asset) {
76 $clone = isset($this->clones[$asset]) ? $this->clones[$asset] : null;
77 if (in_array($needle,
array($asset, $clone),
true)) {
78 unset($this->clones[$asset], $this->assets[$i]);
92 throw new \InvalidArgumentException(
'Leaf not found.');
97 foreach ($this->assets as $i => $asset) {
98 $clone = isset($this->clones[$asset]) ? $this->clones[$asset] : null;
99 if (in_array($needle,
array($asset, $clone),
true)) {
100 unset($this->clones[$asset]);
101 $this->assets[$i] = $replacement;
115 throw new \InvalidArgumentException(
'Leaf not found.');
120 $this->filters->ensure($filter);
125 return $this->filters->all();
130 $this->filters->clear();
131 $this->clones = new \SplObjectStorage();
138 foreach ($this as $asset) {
139 $asset->load($additionalFilter);
140 $parts[] = $asset->getContent();
143 $this->content = implode(
"\n", $parts);
150 foreach ($this as $asset) {
151 $parts[] = $asset->dump($additionalFilter);
154 return implode(
"\n", $parts);
197 if (!count($this->assets)) {
202 foreach ($this as $asset) {
203 $assetMtime = $asset->getLastModified();
204 if ($assetMtime > $mtime) {
205 $mtime = $assetMtime;
229 foreach ($this as $asset) {
230 $asset->setValues(array_intersect_key($values, array_flip($asset->getVars())));
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
Iterates over an asset collection.
getIterator()
Returns an iterator for looping recursively over unique leaves.
clearFilters()
Clears all filters from the current asset.
Asset collection filter iterator.
__construct($assets=array(), $filters=array(), $sourceRoot=null, array $vars=array())
Constructor.
removeLeaf(AssetInterface $needle, $graceful=false)
Removes a leaf.
ensureFilter(FilterInterface $filter)
Ensures the current asset includes the supplied filter.
getSourcePath()
Returns the relative path for the source asset.
replaceLeaf(AssetInterface $needle, AssetInterface $replacement, $graceful=false)
Replaces an existing leaf with a new one.
dump(FilterInterface $additionalFilter=null)
Applies dump filters and returns the asset as a string.
A filter manipulates an asset at load and dump.
all()
Returns all child assets.
replaceLeaf(AssetInterface $needle, AssetInterface $replacement, $graceful=false)
Replaces an existing leaf with a new one.
add(AssetInterface $asset)
Adds an asset to the current collection.
load(FilterInterface $additionalFilter=null)
Loads the asset into memory and applies load filters.
getTargetPath()
Returns the URL for the current asset.
setValues(array $values)
Sets the values for the asset's variables.
removeLeaf(AssetInterface $leaf, $graceful=false)
Removes a leaf.
An asset has a mutable URL and content and can be loaded and dumped.
Create styles array
The data for the language used.
setContent($content)
Sets the content of the current asset.
getLastModified()
Returns the highest last-modified value of all assets in the current collection.
setTargetPath($targetPath)
Sets the URL for the current asset.
getValues()
Returns the current values for this asset.
getContent()
Returns the loaded content of the current asset.
getSourceDirectory()
Returns the asset's source directory.
getFilters()
Returns an array of filters currently applied.
getVars()
Returns an array of variable names for this asset.