Minify Javascript using via command line.

Paramètres

string $contents: The JavaScript to minify.

1 string reference to 'advagg_ext_minify_js_minify'
advagg_ext_minify_advagg_js_minify_configuration_alter dans advagg_ext_minify/advagg_ext_minify.module
Implements hook_advagg_js_minify_configuration_alter().

Fichier

advagg_ext_minify/advagg_ext_minify.module, line 114

Code

function advagg_ext_minify_js_minify(&$contents) {
    $js_path = \Drupal::config('advagg.settings')->get('root_dir_prefix') . 'advagg_js';
    $temp_file = \Drupal::service("file_system")->tempnam($js_path, 'file_advagg_');
    $new_temp_file = $temp_file . '.js';
    rename($temp_file, $new_temp_file);
    $temp_file_full = advagg_get_relative_path($new_temp_file);
    file_put_contents($new_temp_file, $contents);
    $output = advagg_ext_minify_execute_cmd($temp_file_full, 'js');
    $contents = file_get_contents($output);
    // Cleanup.
    unset($new_temp_file);
    unset($temp_file_full);
    unset($output);
}