You are here

protected function Minifier::execute in Advanced CSS/JS Aggregation 8.3

Same name and namespace in other branches
  1. 8.4 advagg_ext_minify/src/Asset/Minifier.php \Drupal\advagg_ext_minify\Asset\Minifier::execute()

Run the command line.

Parameters

string $ext: The string css or js.

Return value

string The file containing the minified data.

2 calls to Minifier::execute()
Minifier::css in advagg_ext_minify/src/Asset/Minifier.php
Minify CSS using via command line.
Minifier::js in advagg_ext_minify/src/Asset/Minifier.php
Minify Javascript using via command line.

File

advagg_ext_minify/src/Asset/Minifier.php, line 115

Class

Minifier
Optimizes a asset via external minifiers.

Namespace

Drupal\advagg_ext_minify\Asset

Code

protected function execute($ext) {
  $run = $this->config
    ->get($ext . '_cmd');
  $run = str_replace([
    '{%CWD%}',
    '{%IN%}',
    '{%IN_URL_ENC%}',
    '{%OUT%}',
  ], [
    $this->root,
    $this->in,
    urlencode(file_create_url($this->in)),
    escapeshellarg(realpath($this->out)),
  ], $run);

  // Run command and return the output file.
  shell_exec($run);
  return $this->out;
}