Same name in this branch
  1. 6.0.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_bundler\EventSubscriber\MinificationSubscriber
  2. 6.0.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
  3. 6.0.x advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_ext_minify\EventSubscriber\MinificationSubscriber
Same name in other branches
  1. 5.0.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_bundler\EventSubscriber\MinificationSubscriber
  2. 5.0.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber
  3. 5.0.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
  4. 5.0.x advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_ext_minify\EventSubscriber\MinificationSubscriber
  5. 8.x-3.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
  6. 8.x-3.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber
  7. 8.x-3.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
  8. 8.x-3.x advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_ext_minify\EventSubscriber\MinificationSubscriber
  9. 8.x-4.x advagg_bundler/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_bundler\EventSubscriber\MinificationSubscriber
  10. 8.x-4.x advagg_css_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber
  11. 8.x-4.x advagg_js_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_js_minify\EventSubscriber\MinificationSubscriber
  12. 8.x-4.x advagg_ext_minify/src/EventSubscriber/MinificationSubscriber.php \Drupal\advagg_ext_minify\EventSubscriber\MinificationSubscriber

Subscribe to asset optimization events and minify assets.

Hierarchy

  • class \Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MinificationSubscriber

1 string reference to 'MinificationSubscriber'
advagg_css_minify.services.yml dans advagg_css_minify/advagg_css_minify.services.yml
advagg_css_minify/advagg_css_minify.services.yml
1 service uses MinificationSubscriber
advagg.css_subscriber dans advagg_css_minify/advagg_css_minify.services.yml
Drupal\advagg_css_minify\EventSubscriber\MinificationSubscriber

Fichier

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

Namespace

Drupal\advagg_css_minify\EventSubscriber
View 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 asset 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::CSS => [
                'minify',
                0,
            ],
        ];
    }

}

Members

Titre Trier par ordre décroissant Modifiers Object type Résumé
MinificationSubscriber::$minifier protected property The minifier.
MinificationSubscriber::getSubscribedEvents public static function
MinificationSubscriber::minify public function Pass the minification over to the minification service.
MinificationSubscriber::__construct public function Construct the optimizer instance.