function advagg_get_aggregate_info_from_files in Advanced CSS/JS Aggregation 7.2
Given a group of files calculate various hashes and gather meta data.
Parameters
string $type: String; css or js.
array $files_with_meta_data: An array of CSS/JS files.
Return value
array array containing $aggregate_filename, $filenames, $aggregate_filenames_hash, $aggregate_contents_hash
1 call to advagg_get_aggregate_info_from_files()
- advagg_generate_filenames in ./
advagg.inc - Given a group of files calculate what the aggregate filename will be.
File
- ./
advagg.inc, line 473 - Advanced CSS/JS aggregation module.
Code
function advagg_get_aggregate_info_from_files($type, array $files_with_meta_data) {
$filename_hashes = array();
$content_hashes = array();
$filenames = array();
$files_info_filenames = array();
foreach ($files_with_meta_data as $info) {
if (!empty($info['data']) && is_string($info['data'])) {
$files_info_filenames[] = $info['data'];
}
else {
watchdog('advagg', 'Bad data key. File info: <code>@finfo</code>', array(
'@finfo' => var_export($info, TRUE),
));
}
}
// Get filesystem data.
$files_info = advagg_get_info_on_files($files_info_filenames);
foreach ($files_with_meta_data as $info) {
// Skip if not a string or key doesn't exist.
if (!is_string($info['data']) || !array_key_exists($info['data'], $files_info)) {
continue;
}
$filename = $info['data'];
$info += $files_info[$filename];
// Skip if file doesn't exist.
if (empty($info['content_hash'])) {
continue;
}
// Add info to arrays.
$filename_hashes[] = $info['filename_hash'];
$content_hashes[] = $info['content_hash'];
$filenames[$filename] = $info;
}
// Generate filename.
$aggregate_filenames_hash = drupal_hash_base64(implode('', $filename_hashes));
$aggregate_contents_hash = drupal_hash_base64(implode('', $content_hashes));
$aggregate_filename = advagg_build_filename($type, $aggregate_filenames_hash, $aggregate_contents_hash);
return array(
$aggregate_filename,
$filenames,
$aggregate_filenames_hash,
$aggregate_contents_hash,
);
}