function CssCollectionOptimizer::generateHash

Same name in other branches
  1. 9 core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php \Drupal\Core\Asset\CssCollectionOptimizer::generateHash()
  2. 10 core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php \Drupal\Core\Asset\CssCollectionOptimizer::generateHash()

Generate a hash for a given group of CSS assets.

Parameters

array $css_group: A group of CSS assets.

Return value

string A hash to uniquely identify the given group of CSS assets.

1 call to CssCollectionOptimizer::generateHash()
CssCollectionOptimizer::optimize in core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php
The cache file name is retrieved on a page load via a lookup variable that contains an associative array. The array key is the hash of the file names in $css while the value is the cache file name. The cache file is generated in two cases. First, if…

File

core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php, line 172

Class

CssCollectionOptimizer
Optimizes CSS assets.

Namespace

Drupal\Core\Asset

Code

protected function generateHash(array $css_group) {
    $css_data = [];
    foreach ($css_group['items'] as $css_file) {
        $css_data[] = $css_file['data'];
    }
    return hash('sha256', serialize($css_data));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.