Пример #1
0
 /**
  * Combines assets matching a pattern to a single file asset, optionally applies filters.
  *
  * @param  AssetCollection $assets
  * @param  string          $name
  * @param  array           $options
  * @return AssetCollection
  */
 protected function doCombine(AssetCollection $assets, $name, $options = [])
 {
     extract($options);
     $combine = new AssetCollection();
     $pattern = $this->globToRegex($pattern);
     foreach ($assets as $asset) {
         if (preg_match($pattern, $asset->getName())) {
             $combine->add($asset);
         }
     }
     $file = strtr($this->cache, ['%name%' => $name]);
     if ($names = $combine->names() and $file = $this->doCache($combine, $file, $filters)) {
         $assets->remove(array_slice($names, 1));
         $assets->replace(array_shift($names), $this->factory->create($name, $file));
     }
     return $assets;
 }