class MinificationSubscriber in Advanced CSS/JS Aggregation 8.3
Same name in this branch
- 8.3 advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_ext_minify\EventSubscriber\MinificationSubscriber
- 8.3 advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber
- 8.3 advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
- 8.3 advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
Same name and namespace in other branches
- 8.4 advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
Subscribe to asset optimization events and minify assets.
Hierarchy
- class \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of MinificationSubscriber
1 string reference to 'MinificationSubscriber'
- advagg_js_minify.services.yml in advagg_js_minify/
advagg_js_minify.services.yml - advagg_js_minify/advagg_js_minify.services.yml
1 service uses MinificationSubscriber
File
- advagg_bundler/
src/ EventSubscriber/ MinificationSubscriber.php, line 12
Namespace
Drupal\advagg_js_minify\EventSubscriberView source
class MinificationSubscriber implements EventSubscriberInterface {
/**
* The minifier.
*
* @var \Drupal\advagg\Asset\SingleAssetOptimizerBase
*/
protected $minifier;
/**
* Construct the optimizer instance.
*
* @param \Drupal\advagg\Asset\SingleAssetOptimizerBase $minifier
* The minifier.
*/
public function __construct(SingleAssetOptimizerBase $minifier) {
$this->minifier = $minifier;
}
/**
* Pass the minification over to the minification service.
*
* @param \Drupal\advagg\Asset\AssetOptimizationEvent $asset
* The optimization event.
*/
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);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
AssetOptimizationEvent::JS => [
'minify',
0,
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MinificationSubscriber:: |
protected | property | The minifier. | |
MinificationSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
MinificationSubscriber:: |
public | function | Pass the minification over to the minification service. | |
MinificationSubscriber:: |
public | function | Construct the optimizer instance. |