You are here

public function MinificationSubscriber::minify in Advanced CSS/JS Aggregation 8.3

Same name in this branch
  1. 8.3 advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber::minify()
  2. 8.3 advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber::minify()
  3. 8.3 advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber::minify()
Same name and namespace in other branches
  1. 8.4 advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber::minify()

Pass the minification over to the minification service.

Parameters

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

File

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

Class

MinificationSubscriber
Subscribe to asset optimization events and minify assets.

Namespace

Drupal\advagg_css_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);
}