private function AssetFactory::applyWorkers

Filters an asset collection through the factory workers.

Each leaf asset will be processed first, followed by the asset collection itself.

Parameters

AssetCollectionInterface $asset An asset collection:

Return value

AssetCollectionInterface

1 call to AssetFactory::applyWorkers()
AssetFactory::createAsset in drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/AssetFactory.php
Creates a new asset.

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Factory/AssetFactory.php, line 344

Class

AssetFactory
The asset factory creates asset objects.

Namespace

Assetic\Factory

Code

private function applyWorkers(AssetCollectionInterface $asset) {
  foreach ($asset as $leaf) {
    foreach ($this->workers as $worker) {
      $retval = $worker
        ->process($leaf);
      if ($retval instanceof AssetInterface && $leaf !== $retval) {
        $asset
          ->replaceLeaf($leaf, $retval);
      }
    }
  }
  foreach ($this->workers as $worker) {
    $retval = $worker
      ->process($asset);
    if ($retval instanceof AssetInterface) {
      $asset = $retval;
    }
  }
  return $asset instanceof AssetCollectionInterface ? $asset : $this
    ->createAssetCollection(array(
    $asset,
  ));
}