Returns a cache key for the current asset.
The key is composed of everything but an asset's content:
AssetInterface $asset The asset:
FilterInterface $additionalFilter Any additional filter being applied:
string $salt Salt for the key:
string A key for identifying the current asset
private static function getCacheKey(AssetInterface $asset, FilterInterface $additionalFilter = null, $salt = '') {
if ($additionalFilter) {
$asset = clone $asset;
$asset
->ensureFilter($additionalFilter);
}
$cacheKey = $asset
->getSourceRoot();
$cacheKey .= $asset
->getSourcePath();
$cacheKey .= $asset
->getTargetPath();
$cacheKey .= $asset
->getLastModified();
foreach ($asset
->getFilters() as $filter) {
if ($filter instanceof HashableInterface) {
$cacheKey .= $filter
->hash();
}
else {
$cacheKey .= serialize($filter);
}
}
if ($values = $asset
->getValues()) {
asort($values);
$cacheKey .= serialize($values);
}
return md5($cacheKey . $salt);
}