当前位置: 首页>>代码示例>>PHP>>正文


PHP StringAsset::ensureFilter方法代码示例

本文整理汇总了PHP中Assetic\Asset\StringAsset::ensureFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP StringAsset::ensureFilter方法的具体用法?PHP StringAsset::ensureFilter怎么用?PHP StringAsset::ensureFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assetic\Asset\StringAsset的用法示例。


在下文中一共展示了StringAsset::ensureFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFilterDump

 public function testFilterDump()
 {
     $expected = 'body{baz:foo;foo:new;too:me}div.other,div.test{border:1px solid black}';
     $inputCss = 'body { foo:bar; too: me;} body { baz:foo; } body { foo: new }
     div.test { border: 1px solid black; }
     div.other { border: 1px solid black} ';
     $asset = new StringAsset($inputCss);
     $asset->ensureFilter($this->filter);
     $result = $asset->dump();
     $this->assertEquals($expected, $result);
 }
开发者ID:renaatdemuynck,项目名称:css-optimizer,代码行数:11,代码来源:CssOptimizeFilterTest.php

示例2: processFile

 public function processFile($path, $config = [])
 {
     $rel = b::param('rel', false, $config);
     $url = b::param('url', false, $config);
     $useGlobalFilters = b::param('useGlobalFilters', true, $config);
     // get the file
     $file = $this->getFile($path);
     $root = pathinfo($path)['dirname'];
     $ext = pathinfo($path)['extension'];
     // get it's tree
     $content = $file->getContent();
     if (empty($content)) {
         return $content;
     }
     $inc = [];
     // parse the string
     $found = $this->parseString($content, $root);
     if (b::param('filterOnly', false, $config) === 'true') {
         $found = ['filter' => $found['filter']];
     }
     $tree = $this->getCombinedTree($found, $ext);
     $reduce = function ($items, $reduce) {
         $resp = [];
         foreach ($items as $key => $files) {
             $resp[] = $key;
             $resp += $reduce($files, $reduce);
         }
         return $resp;
     };
     // loop through each file and append
     foreach (array_unique($reduce($tree, $reduce)) as $f) {
         if ($f === $path) {
             continue;
         }
         $inc[] = $this->processFile($f);
     }
     $source = false;
     $sourcePath = false;
     $targetPath = false;
     if ($url) {
         $parts = parse_url($url);
         $source = "{$parts['scheme']}://{$parts['host']}";
         $targetPath = trim($parts['path'], '/');
         $sourcePath = $targetPath . '/' . trim($rel, '/');
     }
     $inc[] = $content;
     $a = new StringAsset(implode("\n", $inc), [], $source, $sourcePath);
     if ($targetPath) {
         $a->setTargetPath($targetPath);
     }
     // use filters
     if ($useGlobalFilters !== false) {
         if (array_key_exists($ext, $this->_filters)) {
             foreach ($this->_filters[$ext] as $filter) {
                 if ($filter[1] === false and b::env() === 'dev') {
                     continue;
                 }
                 $a->ensureFilter(new $filter[0]());
             }
         }
         foreach ($this->_filters['*'] as $filter) {
             if ($filter[1] === false and b::env() === 'dev') {
                 continue;
             }
             $a->ensureFilter(new $filter[0]());
         }
     }
     $a->ensureFilter(new CssRewriteFilter());
     return trim($a->dump());
 }
开发者ID:boltphp,项目名称:core,代码行数:70,代码来源:assets.php

示例3: getStringAsset

 /**
  * Gets the string asset
  *
  * @param  string      $content
  * @return StringAsset
  */
 private function getStringAsset($content)
 {
     $stringAsset = new StringAsset($content);
     $stringAsset->ensureFilter($this->filter);
     return $stringAsset;
 }
开发者ID:boskee,项目名称:HearsayRequireJSBundle,代码行数:12,代码来源:RJsFilterTest.php


注:本文中的Assetic\Asset\StringAsset::ensureFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。