Filters an asset collection through the factory workers.
Each leaf asset will be processed first, followed by the asset collection itself.
AssetCollectionInterface $asset An asset collection:
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,
));
}