Create the aggregate if it does not exist; using HTTPRL if possible.

Paramètres

array $plans: An array of aggregate file names.

string $type: String; css or js.

Return value

array An array of what was done when generating the file.

1 call to advagg_create_aggregate_files()
advagg_build_aggregate_plans dans ./advagg.inc
Replacement for drupal_build_css_cache() and drupal_build_js_cache().

Fichier

./advagg.inc, line 1563

Code

function advagg_create_aggregate_files(array $plans, $type) {
    $filenames = array();
    $return = array();
    foreach ($plans as $plan) {
        $filenames[] = $plan['filename'];
    }
    // If the httprl module exists and we want to use it.
    if (module_exists('httprl') && variable_get('advagg_use_httprl', ADVAGG_USE_HTTPRL) && (is_callable('httprl_is_background_callback_capable') && httprl_is_background_callback_capable() || !is_callable('httprl_is_background_callback_capable'))) {
        if (variable_get('advagg_fast_filesystem', ADVAGG_FAST_FILESYSTEM)) {
            list($css_path, $js_path) = advagg_get_root_files_dir();
            foreach ($filenames as $key => $filename) {
                if ($type === 'css') {
                    $uri = $css_path[0] . '/' . $filename;
                }
                elseif ($type === 'js') {
                    $uri = $js_path[0] . '/' . $filename;
                }
                if (file_exists($uri)) {
                    unset($filenames[$key]);
                }
            }
        }
        if (!empty($filenames)) {
            // Setup callback options array; call function in the background.
            $callback_options = array(
                array(
                    'function' => 'advagg_build_aggregates',
                ),
                $filenames,
                $type,
            );
            // Queue up the request.
            httprl_queue_background_callback($callback_options);
            // Execute request.
            $return = httprl_send_request();
        }
    }
    else {
        $return = advagg_build_aggregates($filenames, $type);
    }
    return $return;
}