Builds the requested CSS/JS aggregates.
Parameters
array $filenames: Array of AdvAgg filenames to generate.
string $type: String: css or js.
Return value
array Array keyed by filename, value is result from advagg_missing_create_file().
1 call to advagg_build_aggregates()
- advagg_create_aggregate_files in ./
advagg.inc - Create the aggregate if it does not exist; using HTTPRL if possible.
1 string reference to 'advagg_build_aggregates'
- advagg_create_aggregate_files in ./
advagg.inc - Create the aggregate if it does not exist; using HTTPRL if possible.
File
-
./
advagg.module, line 3745
Code
function advagg_build_aggregates(array $filenames, $type) {
// Check input values.
if (empty($filenames)) {
return array();
}
if (empty($type)) {
$filename = reset($filenames);
$type = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
}
// Call the file generation function directly.
module_load_include('inc', 'advagg', 'advagg.missing');
list($css_path, $js_path) = advagg_get_root_files_dir();
$return = array();
foreach ($filenames as $filename) {
// Skip if the file exists.
if ($type === 'css') {
$uri = $css_path[0] . '/' . $filename;
}
elseif ($type === 'js') {
$uri = $js_path[0] . '/' . $filename;
}
if (file_exists($uri)) {
continue;
}
// Only create the file if we have a lock.
$lock_name = 'advagg_' . $filename;
if (variable_get('advagg_no_locks', ADVAGG_NO_LOCKS)) {
$return[$filename] = advagg_missing_create_file($filename);
}
elseif (lock_acquire($lock_name, 10)) {
$return[$filename] = advagg_missing_create_file($filename);
lock_release($lock_name);
}
}
return $return;
}