Same name in other branches
  1. 8.x-3.x advagg_old_ie_compatibility/src/EventSubscriber/CssSubscriber.php \Drupal\advagg_old_ie_compatibility\EventSubscriber\CssSubscriber::scan()
  2. 8.x-4.x advagg_old_ie_compatibility/src/EventSubscriber/CssSubscriber.php \Drupal\advagg_old_ie_compatibility\EventSubscriber\CssSubscriber::scan()

Scan the asset, count the selectors and save selector count to asset array.

The counting method is very rough and may have inaccuracies - especially if there are media queries in the file. Since we only care about the maximum, this is acceptable since that reduces performance hit and an exact number is unimportant.

Paramètres

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

Fichier

advagg_old_ie_compatibility/src/EventSubscriber/CssSubscriber.php, line 24

Classe

CssSubscriber
Subscribe to CSs asset optimization events and count selectors.

Namespace

Drupal\advagg_old_ie_compatibility\EventSubscriber

Code

public function scan(AssetOptimizationEvent $asset) {
    $asset_array = $asset->getAsset();
    $asset_array['selectors'] = substr_count($asset->getContent(), '{');
    $asset->setAsset($asset_array);
}