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;
sprintf('%.4f', $callTime)
getSourceDirectory()
Returns the asset's source directory.
setValues(array $values)
Sets the values for the asset's variables.
getFilters()
Returns an array of filters currently applied.
ensureFilter(FilterInterface $filter)
Ensures the current asset includes the supplied filter.
doLoad($content, FilterInterface $additionalFilter=null)
Encapsulates asset loading logic.
setContent($content)
Sets the content of the current asset.
setTargetPath($targetPath)
Sets the URL for the current asset.
dump(FilterInterface $additionalFilter=null)
Applies dump filters and returns the asset as a string.
getContent()
Returns the loaded content of the current asset.
getSourcePath()
Returns the relative path for the source asset.
__construct($filters=array(), $sourceRoot=null, $sourcePath=null, array $vars=array())
Constructor.
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
getTargetPath()
Returns the URL for the current asset.
clearFilters()
Clears all filters from the current asset.
getValues()
Returns the current values for this asset.
getVars()
Returns an array of variable names for this asset.
An exception for terminatinating execution or to throw for unit testing.
An asset has a mutable URL and content and can be loaded and dumped.
load(FilterInterface $additionalFilter=null)
Loads the asset into memory and applies load filters.
A filter manipulates an asset at load and dump.