You are here

function advagg_sri_advagg_save_aggregate_alter in Advanced CSS/JS Aggregation 7.2

Implements hook_advagg_save_aggregate_alter().

Save the hash of the file.

Related topics

File

advagg_sri/advagg_sri.advagg.inc, line 18
Advanced aggregation sri module.

Code

function advagg_sri_advagg_save_aggregate_alter(array &$files_to_save, array $aggregate_settings, array $other_parameters) {

  // * @param array $files_to_save
  // *   Array($uri => $contents).
  // * @param array $aggregate_settings
  // *   Array of settings.
  // * @param array $other_parameters
  // *   Array of containing $files and $type.
  foreach ($files_to_save as $uri => $contents) {

    // Skip gzip/brotli files.
    $ext = strtolower(pathinfo($uri, PATHINFO_EXTENSION));
    if ($ext === 'gz' || $ext === 'br') {
      continue;
    }
    $hashes = advagg_sri_compute_hashes($contents);

    // Save to the database.
    $filename = basename($uri);
    advagg_sri_set_filename_hashes($filename, $hashes);
  }
}