コード例 #1
0
 public function dump(AssetInterface $asset)
 {
     $writer = new \Assetic\AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables'));
     $ref = new \ReflectionMethod($writer, 'getCombinations');
     $ref->setAccessible(true);
     $name = $asset->getSourcePath();
     $type = substr($name, strrpos($name, '.') + 1);
     switch ($type) {
         case 'coffee':
             $asset->ensureFilter($this->container->get('assetic.filter.coffee'));
             $type = 'js';
             break;
         case 'less':
             $asset->ensureFilter($this->container->get('assetic.filter.less'));
             $type = 'css';
             break;
     }
     $combinations = $ref->invoke($writer, $asset->getVars());
     $asset->setValues($combinations[0]);
     $asset->load();
     $content = $asset->getContent();
     // because the assetic cssrewrite makes bullshit here, we need to reimplement the filter
     if ($type === 'css') {
         $content = $this->cssFilter($content, '/' . dirname($asset->getSourcePath()));
     }
     return $content;
 }
コード例 #2
0
 public function process(AssetInterface $asset)
 {
     if (0 < preg_match($this->pattern, $asset->getTargetUrl())) {
         $asset->ensureFilter($this->filter);
     }
     return $asset;
 }
コード例 #3
0
ファイル: LazyAsset.php プロジェクト: puli/assetic-extension
 private function createInnerAsset()
 {
     if ($this->innerAsset) {
         throw new RuntimeException('The inner asset must be created only once.');
     }
     $this->innerAsset = $this->factory->parseInputWithFixedValues($this->input, $this->currentDir, $this->roots, $this->vars, $this->values);
     foreach ($this->filters as $filter) {
         $this->innerAsset->ensureFilter($filter);
     }
     if (null !== $this->content) {
         $this->innerAsset->setContent($this->content);
     }
     if (null !== $this->targetPath) {
         $this->innerAsset->setTargetPath($this->targetPath);
     }
     // GC
     $this->factory = null;
     $this->input = null;
     $this->currentDir = null;
     $this->roots = null;
     $this->content = null;
     $this->targetPath = null;
 }
コード例 #4
0
ファイル: Manager.php プロジェクト: mpoiriert/nucleus
 private function applyFilters(AssetInterface $asset, $fileType)
 {
     if ($fileType == 'css') {
         $asset->ensureFilter(new CssRewriteFilter());
         //NECESSARY FOR IMAGE PATHS
     }
 }
コード例 #5
0
 public function process(AssetInterface $asset, AssetFactory $factory)
 {
     if (self::CHECK_SOURCE === (self::CHECK_SOURCE & $this->flags) && preg_match($this->pattern, $asset->getSourcePath()) || self::CHECK_TARGET === (self::CHECK_TARGET & $this->flags) && preg_match($this->pattern, $asset->getTargetPath())) {
         $asset->ensureFilter($this->filter);
     }
 }
コード例 #6
0
 /**
  * Ensure that the filters as filter are set.
  *
  * @param   AssetInterface  $asset
  * @param   mixed           $filter    Either an instance of FilterInterface or a classname.
  * @throws  Exception\RuntimeException
  */
 protected function ensureByFilter(AssetInterface $asset, $filter)
 {
     if ($filter instanceof FilterInterface) {
         $filterInstance = $filter;
         $asset->ensureFilter($filterInstance);
         return;
     }
     $filterClass = $filter;
     if (!is_subclass_of($filterClass, 'Assetic\\Filter\\FilterInterface', true)) {
         $filterClass .= substr($filterClass, -6) === 'Filter' ? '' : 'Filter';
         $filterClass = 'Assetic\\Filter\\' . $filterClass;
     }
     if (!class_exists($filterClass)) {
         throw new Exception\RuntimeException('No filter found for ' . $filter);
     }
     if (!isset($this->filterInstances[$filterClass])) {
         $this->filterInstances[$filterClass] = new $filterClass();
     }
     $filterInstance = $this->filterInstances[$filterClass];
     $asset->ensureFilter($filterInstance);
 }
コード例 #7
0
 /**
  * Ensures the current asset includes the supplied filter.
  *
  * @param FilterInterface $filter
  */
 public function ensureFilter(FilterInterface $filter)
 {
     $this->asset->ensureFilter($filter);
 }
コード例 #8
0
 /**
  * Clean filters, remove css-rewrite filter and inherit collection filters.
  *
  * @param AssetInterface $asset            The asset.
  * @param array          $inheritedFilters The inherited filters.
  *
  * @return void
  */
 private function cleanFilters(AssetInterface $asset, array $inheritedFilters)
 {
     // remove css-rewrite filter
     $filters = $asset->getFilters();
     $asset->clearFilters();
     foreach ($filters as $filter) {
         if (!$filter instanceof CssRewriteFilter) {
             $asset->ensureFilter($filter);
         }
     }
     // inherit filters
     foreach ($inheritedFilters as $filter) {
         if (!$filter instanceof CssRewriteFilter) {
             $asset->ensureFilter($filter);
         }
     }
 }
コード例 #9
0
 /**
  * Processes an asset.
  *
  * @param AssetInterface $asset An asset
  * @param Boolean        $debug Debug mode
  */
 public function process(AssetInterface $asset, $debug = false)
 {
     if ((null === $this->debug || $this->debug === $debug) && preg_match($this->pattern, $asset->getTargetUrl())) {
         $asset->ensureFilter($this->filter);
     }
 }