function advagg_cached_bundle_get in Advanced CSS/JS Aggregation 7
Same name and namespace in other branches
- 6 advagg.module \advagg_cached_bundle_get()
Get a bundle from the cache & verify it is good.
Parameters
$cached_data_key: cache key for the cache_advagg_bundle_reuse table.
$debug_name: Name to output in the array if debugging is enabled.
Return value
data from the cache.
3 calls to advagg_cached_bundle_get()
- advagg_bundler_advagg_filenames_alter in advagg_bundler/
advagg_bundler.module - Implements hook_advagg_filenames_alter().
- advagg_css_js_file_builder in ./
advagg.module - Aggregate CSS/JS files, putting them in the files directory.
- advagg_find_existing_bundle in ./
advagg.module - Given a list of files, see if a bundle already exists containing all of those files. If in strict mode then the file count has to be the same.
File
- ./
advagg.module, line 970 - Advanced CSS/JS aggregation module
Code
function advagg_cached_bundle_get($cached_data_key, $debug_name) {
global $_advagg;
$data = cache_get($cached_data_key, 'cache_advagg_bundle_reuse');
if (!empty($data->data)) {
$data = $data->data;
$bundle_contents = array();
$good = TRUE;
// Debugging.
if (variable_get('advagg_debug', ADVAGG_DEBUG)) {
// Verify cached data is good.
foreach ($data as $filename => $extra) {
if (is_numeric($filename)) {
continue;
}
// Get md5 from aggregated filename.
$b_md5 = explode('/', $filename);
$b_md5 = explode('_', array_pop($b_md5));
$b_md5 = $b_md5[1];
// Lookup bundle and make sure it is valid.
if (!empty($b_md5)) {
list($b_filetype, $b_files) = advagg_get_files_in_bundle($b_md5);
$bundle_contents[$filename] = $b_files;
if (empty($b_files)) {
$good = FALSE;
}
}
}
$_advagg['debug'][$debug_name][] = array(
'key' => $cached_data_key,
'cache' => $data,
'bundle_contents' => $bundle_contents,
);
}
if ($good) {
return $data;
}
}
return FALSE;
}