Esempio n. 1
0
 /**
  * Create a new AssetCollection instance for the given group.
  *
  * @param  string                         $name
  * @param  bool                           $overwrite force writing
  * @return \Assetic\Asset\AssetCollection
  */
 public function createGroup($name, $overwrite = false)
 {
     if (isset($this->groups[$name])) {
         return $this->groups[$name];
     }
     $assets = $this->createAssetArray($name);
     $filters = $this->createFilterArray($name);
     $coll = new AssetCollection($assets, $filters);
     if ($output = $this->getConfig($name, 'output')) {
         $coll->setTargetPath($output);
     }
     // check output cache
     $write_output = true;
     if (!$overwrite) {
         if (file_exists($output = public_path($coll->getTargetPath()))) {
             $output_mtime = filemtime($output);
             $asset_mtime = $coll->getLastModified();
             if ($asset_mtime && $output_mtime >= $asset_mtime) {
                 $write_output = false;
             }
         }
     }
     // store assets
     if ($overwrite || $write_output) {
         $writer = new AssetWriter(public_path());
         $writer->writeAsset($coll);
     }
     return $this->groups[$name] = $coll;
 }
Esempio n. 2
0
 public function __construct(AssetCollection $coll)
 {
     $this->assets = $coll->all();
     $this->filters = $coll->getFilters();
     $this->output = $coll->getTargetPath();
     if (false === ($pos = strpos($this->output, '.'))) {
         $this->output .= '_*';
     } else {
         $this->output = substr($this->output, 0, $pos) . '_*' . substr($this->output, $pos);
     }
 }