/**
  * {@inheritdoc}
  *
  * @throws RuntimeException If the current directory has not yet been set.
  */
 public function replaceLeaf(AssetInterface $needle, AssetInterface $replacement, $graceful = false)
 {
     if (!$this->innerCollection) {
         $this->loadCollection();
     }
     return $this->innerCollection->replaceLeaf($needle, $replacement, $graceful);
 }
Exemplo n.º 2
0
 /**
  * Filters an asset collection through the factory workers.
  *
  * Each leaf asset will be processed first, followed by the asset
  * collection itself.
  *
  * @param AssetCollectionInterface $asset An asset collection
  *
  * @return AssetCollectionInterface
  */
 private function applyWorkers(AssetCollectionInterface $asset)
 {
     foreach ($asset as $leaf) {
         foreach ($this->workers as $worker) {
             $retval = $worker->process($leaf, $this);
             if ($retval instanceof AssetInterface && $leaf !== $retval) {
                 $asset->replaceLeaf($leaf, $retval);
             }
         }
     }
     foreach ($this->workers as $worker) {
         $retval = $worker->process($asset, $this);
         if ($retval instanceof AssetInterface) {
             $asset = $retval;
         }
     }
     return $asset instanceof AssetCollectionInterface ? $asset : $this->createAssetCollection(array($asset));
 }
 /**
  * {@inheritdoc}
  */
 public function replaceLeaf(AssetInterface $needle, AssetInterface $replacement, $graceful = false)
 {
     return $this->assetCollection->replaceLeaf($needle, $replacement, $graceful);
 }