Same name in other branches
  1. 5.0.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::optimizeFile()
  2. 6.0.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::optimizeFile()
  3. 8.x-4.x src/Asset/JsOptimizer.php \Drupal\advagg\Asset\JsOptimizer::optimizeFile()

Overrides AssetOptimizer::optimizeFile

Fichier

src/Asset/JsOptimizer.php, line 124

Classe

JsOptimizer
The JavaScript Optimizer.

Namespace

Drupal\advagg\Asset

Code

protected function optimizeFile(array &$asset, array $data) {
    $asset_event = new AssetOptimizationEvent($data['contents'], $asset, $data);
    $this->eventDispatcher
        ->dispatch(AssetOptimizationEvent::JS, $asset_event);
    $contents = $asset_event->getContent();
    $asset = $asset_event->getAsset();
    // If file contents are unaltered return FALSE.
    if ($contents === $data['contents'] && !$this->gZip) {
        return FALSE;
    }
    return $this->writeFile($contents, $data['cid']);
}