51 $this->sourceDir = dirname(
"$sourceRoot/$sourcePath");
54 $this->values =
array();
55 $this->loaded =
false;
65 $this->filters->ensure($filter);
70 return $this->filters->all();
75 $this->filters->clear();
87 if ($additionalFilter) {
88 $filter->ensure($additionalFilter);
94 $filter->filterLoad($asset);
95 $this->content = $asset->getContent();
102 if (!$this->loaded) {
107 if ($additionalFilter) {
108 $filter->ensure($additionalFilter);
111 $asset = clone $this;
112 $filter->filterDump($asset);
114 return $asset->getContent();
150 foreach ($this->vars as $var) {
152 throw new \RuntimeException(sprintf(
'The asset target path "%s" must contain the variable "{%s}".',
$targetPath, $var));
167 foreach ($values as $var => $v) {
168 if (!in_array($var, $this->vars,
true)) {
169 throw new \InvalidArgumentException(sprintf(
'The asset with source path "%s" has no variable named "%s".', $this->sourcePath, $var));
174 $this->loaded =
false;
ensureFilter(FilterInterface $filter)
Ensures the current asset includes the supplied filter.
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
getSourcePath()
Returns the relative path for the source asset.
__construct($filters=array(), $sourceRoot=null, $sourcePath=null, array $vars=array())
Constructor.
getFilters()
Returns an array of filters currently applied.
getContent()
Returns the loaded content of the current asset.
load(FilterInterface $additionalFilter=null)
Loads the asset into memory and applies load filters.
doLoad($content, FilterInterface $additionalFilter=null)
Encapsulates asset loading logic.
getSourceDirectory()
Returns the asset's source directory.
setValues(array $values)
Sets the values for the asset's variables.
A filter manipulates an asset at load and dump.
dump(FilterInterface $additionalFilter=null)
Applies dump filters and returns the asset as a string.
getVars()
Returns an array of variable names for this asset.
An asset has a mutable URL and content and can be loaded and dumped.
getTargetPath()
Returns the URL for the current asset.
Create styles array
The data for the language used.
setTargetPath($targetPath)
Sets the URL for the current asset.
getValues()
Returns the current values for this asset.
setContent($content)
Sets the content of the current asset.
clearFilters()
Clears all filters from the current asset.