Generate the js minify configuration.

Return value

array Array($options, $description, $compressors, $functions).

1 call to JsOptimizer::getConfiguration()
JsOptimizer::optimize dans advagg_js_minify/src/Asset/JsOptimizer.php

Fichier

advagg_js_minify/src/Asset/JsOptimizer.php, line 89

Classe

JsOptimizer
Optimizes a JavaScript asset.

Namespace

Drupal\advagg_js_minify\Asset

Code

public function getConfiguration() {
    // Set the defaults.
    $description = '';
    $options = [
        0 => t('Disabled'),
        1 => t('JSMin+ ~1300ms'),
        // 2 => t('Packer ~500ms'),
        // 3 is JSMin c extension.
4 => t('JShrink ~1000ms'),
        5 => t('JSqueeze ~600ms'),
    ];
    if (function_exists('jsmin')) {
        $options[3] = t('JSMin ~2ms');
        $description .= t('JSMin is the very fast C complied version. Recommend using it.');
    }
    else {
        $description .= t('You can use the much faster C version of JSMin (~2ms) by installing the <a href="@php_jsmin">JSMin PHP Extension</a> on this server.', [
            '@php_jsmin' => 'https://github.com/sqmk/pecl-jsmin/',
        ]);
    }
    $minifiers = [
        1 => 'jsminplus',
        2 => 'packer',
        4 => 'jshrink',
        5 => 'jsqueeze',
    ];
    if (function_exists('jsmin')) {
        $minifiers[3] = 'jsmin';
    }
    $functions = [
        1 => [
            $this,
            'minifyJsminplus',
        ],
        2 => [
            $this,
            'minifyJspacker',
        ],
        3 => [
            $this,
            'minifyJsmin',
        ],
        4 => [
            $this,
            'minifyJshrink',
        ],
        5 => [
            $this,
            'minifyJsqueeze',
        ],
    ];
    // Allow for other modules to alter this list.
    $options_desc = [
        $options,
        $description,
    ];
    // Call hook_advagg_js_minify_configuration_alter().
    $this->moduleHandler
        ->alter('advagg_js_minify_configuration', $options_desc, $minifiers, $functions);
    list($options, $description) = $options_desc;
    return [
        $options,
        $description,
        $minifiers,
        $functions,
    ];
}