36 $this->asset->ensureFilter($filter);
41 return $this->asset->getFilters();
46 $this->asset->clearFilters();
51 $cacheKey = self::getCacheKey($this->asset, $additionalFilter,
'load');
52 if ($this->cache->has($cacheKey)) {
53 $this->asset->setContent($this->cache->get($cacheKey));
58 $this->asset->load($additionalFilter);
59 $this->cache->set($cacheKey, $this->asset->getContent());
64 $cacheKey = self::getCacheKey($this->asset, $additionalFilter,
'dump');
65 if ($this->cache->has($cacheKey)) {
66 return $this->cache->get($cacheKey);
69 $content = $this->asset->dump($additionalFilter);
70 $this->cache->set($cacheKey, $content);
77 return $this->asset->getContent();
82 $this->asset->setContent($content);
87 return $this->asset->getSourceRoot();
92 return $this->asset->getSourcePath();
97 return $this->asset->getSourceDirectory();
102 return $this->asset->getTargetPath();
107 $this->asset->setTargetPath($targetPath);
112 return $this->asset->getLastModified();
117 return $this->asset->getVars();
122 $this->asset->setValues($values);
127 return $this->asset->getValues();
149 if ($additionalFilter) {
151 $asset->ensureFilter($additionalFilter);
161 $cacheKey .= $filter->hash();
163 $cacheKey .= serialize($filter);
169 $cacheKey .= serialize($values);
172 return md5($cacheKey.$salt);
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
getSourceRoot()
Returns an absolute path or URL to the source asset's root directory.
Caches an asset to avoid the cost of loading and dumping.
getTargetPath()
Returns the URL for the current asset.
getValues()
Returns the current values for this asset.
setTargetPath($targetPath)
Sets the URL for the current asset.
getContent()
Returns the loaded content of the current asset.
getSourcePath()
Returns the relative path for the source asset.
getLastModified()
Returns the time the current asset was last modified.
setContent($content)
Sets the content of the current asset.
__construct(AssetInterface $asset, CacheInterface $cache)
getFilters()
Returns an array of filters currently applied.
getVars()
Returns an array of variable names for this asset.
A filter manipulates an asset at load and dump.
load(FilterInterface $additionalFilter=null)
Loads the asset into memory and applies load filters.
setValues(array $values)
Sets the values for the asset's variables.
static getCacheKey(AssetInterface $asset, FilterInterface $additionalFilter=null, $salt='')
Returns a cache key for the current asset.
getSourceDirectory()
Returns the asset's source directory.
getLastModified()
Returns the time the current asset was last modified.
getSourcePath()
Returns the relative path for the source asset.
An asset has a mutable URL and content and can be loaded and dumped.
Create styles array
The data for the language used.
dump(FilterInterface $additionalFilter=null)
Applies dump filters and returns the asset as a string.
clearFilters()
Clears all filters from the current asset.
ensureFilter(FilterInterface $filter)
Ensures the current asset includes the supplied filter.
Interface for a cache backend.
getFilters()
Returns an array of filters currently applied.
getTargetPath()
Returns the URL for the current asset.
A filter can implement a hash function.
getValues()
Returns the current values for this asset.