Exemplo n.º 1
0
 public function __construct(AssetCollectionInterface $coll, \SplObjectStorage $clones)
 {
     $this->assets = $coll->all();
     $this->filters = $coll->getFilters();
     $this->output = $coll->getTargetPath();
     $this->clones = $clones;
     if (false === ($pos = strpos($this->output, '.'))) {
         $this->output .= '_*';
     } else {
         $this->output = substr($this->output, 0, $pos) . '_*' . substr($this->output, $pos);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @throws RuntimeException If the current directory has not yet been set.
  */
 public function getValues()
 {
     if (!$this->innerCollection) {
         $this->loadCollection();
     }
     return $this->innerCollection->getValues();
 }
 protected function dumpAssets(Node $node, AssetCollectionInterface $asset, $tagName, $assetPath, array $combination = array())
 {
     $inputs = $this->collectInputs($asset->all(), $combination, $node->getAttribute('inputs'));
     $this->assetFileDumper->dump($assetPath, $inputs);
     $aliasedAssetPath = $this->aliasPrefixer->prefixWithAlias($assetPath);
     $arguments = array(str_replace('\\/', '/', json_encode($aliasedAssetPath)));
     if ($tagName === 'stylesheets') {
         $arguments[] = json_encode('css');
     }
     return $this->twigFunctionName . '(' . implode(', ', $arguments) . ')';
 }
Exemplo n.º 4
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);
 }
 /**
  * Split assets and distribute them over the combined and organized collections.
  *
  * @param AssetCollectionInterface|AssetInterface[] $assets               The assets to split.
  * @param AssetCollectionInterface                  $organizedAssets      The organized assets collection.
  * @param OrganizeAssetsEvent                       $event                The event.
  * @param AssetCollectionInterface                  $combinedAssets       The combined assets collection from the
  *                                                                        parent call.
  * @param FilterRules                               $inheritedFilterRules The filter rules from the parent call.
  * @param array                                     $inheritedFilters     The filters from the parent call.
  *
  * @return \Assetic\Asset\AssetCollection|\Assetic\Asset\AssetCollectionInterface|null
  */
 private function splitAssets(AssetCollectionInterface $assets, AssetCollectionInterface $organizedAssets, OrganizeAssetsEvent $event, AssetCollectionInterface $combinedAssets = null, FilterRules $inheritedFilterRules = null, array $inheritedFilters = [])
 {
     foreach ($assets->all() as $asset) {
         if ($this->determineSkip($asset, $event)) {
             continue;
         }
         $this->cleanFilters($asset, $inheritedFilters);
         if ($this->determineDoSubSplit($asset)) {
             $filterRules = $asset instanceof ExtendedAssetInterface ? $asset->getFilterRules() : null;
             $filterRules = $this->joinFilterRules($filterRules, $inheritedFilterRules);
             $combinedAssets = static::splitAssets($asset, $organizedAssets, $event, $combinedAssets, $filterRules, $asset->getFilters());
         } elseif ($this->determineIsStandalone($asset, $event)) {
             $organizedAssets->add($asset);
             $combinedAssets = null;
         } else {
             if (!$combinedAssets) {
                 $combinedAssets = new AssetCollection([], [], TL_ROOT);
                 $organizedAssets->add($combinedAssets);
             }
             $combinedAssets->add($asset);
         }
     }
     return $combinedAssets;
 }