Minify CSS using via command line.

Paramètres

string $contents: The CSS to minify.

1 string reference to 'advagg_ext_minify_css_minify'
advagg_ext_minify_advagg_css_minify_configuration_alter dans advagg_ext_minify/advagg_ext_minify.module
Implements hook_advagg_css_minify_configuration_alter().

Fichier

advagg_ext_minify/advagg_ext_minify.module, line 137

Code

function advagg_ext_minify_css_minify(&$contents) {
    $css_path = \Drupal::config('advagg.settings')->get('root_dir_prefix') . 'advagg_css';
    $temp_file = \Drupal::service("file_system")->tempnam($css_path, 'file_advagg_');
    $new_temp_file = $temp_file . '.css';
    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, 'css');
    $contents = file_get_contents($output);
    // Cleanup.
    unset($new_temp_file);
    unset($temp_file_full);
    unset($output);
}