Same name in this branch
  1. 8.x-3.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber::minify()
  2. 8.x-3.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber::minify()
Same name in other branches
  1. 5.0.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_bundler\EventSubscriber\MinificationSubscriber::minify()
  2. 5.0.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber::minify()
  3. 5.0.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber::minify()
  4. 6.0.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_bundler\EventSubscriber\MinificationSubscriber::minify()
  5. 6.0.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber::minify()
  6. 6.0.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber::minify()
  7. 8.x-4.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_bundler\EventSubscriber\MinificationSubscriber::minify()
  8. 8.x-4.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber::minify()
  9. 8.x-4.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber::minify()

Pass the minification over to the minification service.

Parameters

\Drupal\advagg\Asset\AssetOptimizationEvent $asset: The optimization event.

File

advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php, line 37

Class

MinificationSubscriber
Subscribe to asset optimization events and minify assets.

Namespace

Drupal\advagg_js_minify\EventSubscriber

Code

public function minify(AssetOptimizationEvent $asset) {
    $content = $asset->getContent();
    $content = $this->minifier
        ->optimize($content, $asset->getAsset(), $asset->getData());
    $this->minifier
        ->addLicense($content, $asset->getAsset()['data']);
    $asset->setContent($content);
}