Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Asset/AssetDumper.php \Drupal\Core\Asset\AssetDumper::dump()
  2. 9 core/lib/Drupal/Core/Asset/AssetDumper.php \Drupal\Core\Asset\AssetDumper::dump()

The file name for the CSS or JS cache file is generated from the hash of the aggregated contents of the files in $data. This forces proxies and browsers to download new CSS when the CSS changes.

Overrides AssetDumperInterface::dump

File

core/lib/Drupal/Core/Asset/AssetDumper.php, line 39

Class

AssetDumper
Dumps a CSS or JavaScript asset.

Namespace

Drupal\Core\Asset

Code

public function dump($data, $file_extension) {
  $path = 'assets://' . $file_extension;

  // Prefix filename to prevent blocking by firewalls which reject files
  // starting with "ad*".
  $filename = $file_extension . '_' . Crypt::hashBase64($data) . '.' . $file_extension;
  $uri = $path . '/' . $filename;
  return $this
    ->dumpToUri($data, $file_extension, $uri);
}