private static function AssetCache::getCacheKey

Returns a cache key for the current asset.

The key is composed of everything but an asset's content:

  • source root
  • source path
  • target url
  • last modified
  • filters

Parameters

AssetInterface $asset The asset:

FilterInterface $additionalFilter Any additional filter being applied:

string $salt Salt for the key:

Return value

string A key for identifying the current asset

2 calls to AssetCache::getCacheKey()
AssetCache::dump in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCache.php
Applies dump filters and returns the asset as a string.
AssetCache::load in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCache.php
Loads the asset into memory and applies load filters.

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCache.php, line 142

Class

AssetCache
Caches an asset to avoid the cost of loading and dumping.

Namespace

Assetic\Asset

Code

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);
}