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


PHP StringAsset::dump方法代码示例

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


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

示例1: testAutomaticLoad

 public function testAutomaticLoad()
 {
     $filter = $this->getMock('Assetic\\Filter\\FilterInterface');
     $filter->expects($this->once())->method('filterLoad');
     $asset = new StringAsset('foo', array($filter));
     $asset->dump();
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:7,代码来源:StringAssetTest.php

示例2: 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

示例3: testFilter

 public function testFilter()
 {
     // Create twig env
     $twig = new \Twig_Environment($this->getLoader());
     // Create twig filter
     $filter = new TwigFilter($twig);
     // Create sample asset
     $asset = new StringAsset("{{ '<' | e('html') }}", array($filter));
     // Test asset content
     $this->assertEquals('&lt;', $asset->dump());
 }
开发者ID:igraal,项目名称:twig-assetic-filter-bundle,代码行数:11,代码来源:FilterTest.php

示例4: combineThenDump

 public function combineThenDump()
 {
     // loop through leaves and add each raw asset
     $parts = array();
     $filtersAdded = $this->filters->all();
     foreach ($this as $asset) {
         if (!$filtersAdded) {
             $this->filters = new FilterCollection($asset->getFilters());
             $filtersAdded = true;
         }
         $parts[] = file_get_contents($asset->getSourceRoot() . '/' . $asset->getSourcePath());
     }
     $combinedAsset = new StringAsset(implode("\n", $parts), $this->filters->all());
     $combinedAsset->setLastModified($this->getLastModified());
     return $combinedAsset->dump();
 }
开发者ID:julesferreira,项目名称:assetic,代码行数:16,代码来源:AssetCollection.php

示例5: 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

示例6: build

 /**
  * Build the asset.
  *
  * @param  bool  $production
  * @return string
  */
 public function build($production = false)
 {
     $filters = $this->prepareFilters($production);
     $asset = new StringAsset($this->getContent(), $filters->all(), dirname($this->absolutePath), basename($this->absolutePath));
     return $asset->dump();
 }
开发者ID:chugga,项目名称:basset,代码行数:12,代码来源:Asset.php

示例7: buildScriptData

 /**
  * Combines the script data from all minified scripts
  */
 protected function buildScriptData($where)
 {
     global $wp_scripts;
     $data = '';
     if (empty($this->scripts[$where])) {
         return '';
     }
     foreach ($this->scripts[$where] as $handle => $filepath) {
         $data .= $wp_scripts->print_extra_script($handle, false);
     }
     $asset = new StringAsset($data, array(new JSMinFilter()));
     return $asset->dump();
 }
开发者ID:bmavus,项目名称:wp-theme-blank,代码行数:16,代码来源:AssetsMinifyInit.php

示例8: buildScriptData

 /**
  * Combines the script data from all minified scripts
  *
  * @param string $where The page's place to dump the scripts in (header or footer)
  * @return string The script to include within the page
  */
 protected function buildScriptData($where)
 {
     $data = '';
     if (empty($this->localized[$where])) {
         return '';
     }
     foreach ($this->localized[$where] as $script) {
         $data .= $script;
     }
     $asset = new StringAsset($data, array(new JSqueezeFilter()));
     return $asset->dump();
 }
开发者ID:Tusko,项目名称:WP-Anatomy,代码行数:18,代码来源:Js.php

示例9: compile

 /**
  * Compile the asset.
  * 
  * @return string
  */
 public function compile()
 {
     $filters = array();
     foreach ($this->filters as $name => $arguments) {
         if (class_exists($filter = "Assetic\\Filter\\{$name}") or class_exists($filter = "Basset\\Filter\\{$name}")) {
             $reflection = new ReflectionClass($filter);
             $filters[] = $reflection->newInstanceArgs((array) $arguments);
         }
     }
     $asset = new StringAsset($this->contents, $filters, dirname($this->path), $this->name);
     return $asset->dump();
 }
开发者ID:jvillasante,项目名称:cubanartjb,代码行数:17,代码来源:asset.php

示例10: run

 /**
  * Compiles a given collection
  * @return void
  */
 public function run()
 {
     app('log')->debug("[ASSETS] Compiling collection '" . $this->collection->id . "'");
     // Collection contents
     $this->collection->contents = '';
     foreach ($this->collection->assets() as $asset) {
         if ($asset->type == 'css') {
             // Rewrite relative URL's
             $rewriteFilter = new \Creolab\Assets\Filters\CSSRewriteFilter($asset);
             // Dump contents
             $contents = $rewriteFilter->dump($asset);
         } else {
             // Dump contents
             $contents = $asset->contents();
         }
         // Assign to contents
         $this->collection->contents .= PHP_EOL . $asset->contents();
         $asset->contents = null;
     }
     // Filters
     $filters = array();
     foreach ($this->collection->filters() as $filter) {
         $filterClass = app('config')->get('assets::filters.' . $filter);
         if (class_exists($filterClass)) {
             $filters[] = new $filterClass();
         } else {
             app('log')->error('[ASSETS] Problem with filter "' . $filter . '". The associated class "' . $filterClass . '" was not found.', array('package' => 'ASSETS', 'module' => 'Compiler'));
         }
     }
     // Create the collection in Assetic
     try {
         // Clear the cache
         app('assets')->clearCache($this->collection->id);
         // Create string asset
         $asset = new StringAsset($this->collection->contents, $filters);
         // Directory
         $cachePath = public_path() . '/' . app('config')->get('assets::cache_path');
         if (!app('files')->exists($cachePath)) {
             app('files')->makeDirectory($cachePath, 0777, true);
         }
         // And write contents
         if ($this->collection->cacheFilePath) {
             app('files')->put($this->collection->cacheFilePath, $asset->dump());
         }
         $this->collection->contents = null;
     } catch (\Exception $e) {
         // echo '<pre>'; print_r($e->getMessage()); echo '</pre>';
         // app('files')->put($this->collection->cacheFilePath, $this->collection->contents());
     }
     // Finished
     app('events')->fire('assets.compiled');
     app('log')->debug("[ASSETS] Collection finished compiling '" . $this->collection->id . "'");
     return $this->collection->contents;
 }
开发者ID:creolab,项目名称:assets,代码行数:58,代码来源:Compiler.php


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