• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Asset\FileAsset类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: process

 /**
  * {@inheritdoc}
  */
 public function process()
 {
     $filters = new FilterCollection(array(new CssRewriteFilter()));
     $assets = new AssetCollection();
     $styles = $this->packageStyles($this->packages);
     foreach ($styles as $package => $packageStyles) {
         foreach ($packageStyles as $style => $paths) {
             foreach ($paths as $path) {
                 // The full path to the CSS file.
                 $assetPath = realpath($path);
                 // The root of the CSS file.
                 $sourceRoot = dirname($path);
                 // The style path to the CSS file when external.
                 $sourcePath = $package . '/' . $style;
                 // Where the final CSS will be generated.
                 $targetPath = $this->componentDir;
                 // Build the asset and add it to the collection.
                 $asset = new FileAsset($assetPath, $filters, $sourceRoot, $sourcePath);
                 $asset->setTargetPath($targetPath);
                 $assets->add($asset);
             }
         }
     }
     $css = $assets->dump();
     if (file_put_contents($this->componentDir . '/require.css', $css) === FALSE) {
         $this->io->write('<error>Error writing require.css to destination</error>');
         return false;
     }
 }
开发者ID:ICHydro,项目名称:anaconda,代码行数:32,代码来源:RequireCssProcess.php


示例2: onTerminate

 public function onTerminate(CarewEvent $carewEvent)
 {
     foreach ($this->finder->in($carewEvent->getArgument('webDir')) as $file) {
         $asset = new FileAsset($file->getPathname(), array($this->getFilter()));
         file_put_contents($file->getPathname(), $asset->dump());
     }
 }
开发者ID:francisbesset,项目名称:carew-assetic,代码行数:7,代码来源:AbstractListener.php


示例3: parseInput

 /**
  * Adds support for pipeline assets.
  *
  * {@inheritdoc}
  */
 protected function parseInput($input, array $options = array())
 {
     if (is_string($input) && '|' == $input[0]) {
         switch (pathinfo($options['output'], PATHINFO_EXTENSION)) {
             case 'js':
                 $type = 'js';
                 break;
             case 'css':
                 $type = 'css';
                 break;
             default:
                 throw new \RuntimeException('Unsupported pipeline asset type provided: ' . $input);
         }
         $assets = new AssetCollection();
         foreach ($this->locator->locatePipelinedAssets(substr($input, 1), $type) as $formula) {
             $filters = array();
             if ($formula['filter']) {
                 $filters[] = $this->getFilter($formula['filter']);
             }
             $asset = new FileAsset($formula['root'] . '/' . $formula['file'], $filters, $options['root'][0], $formula['file']);
             $asset->setTargetPath($formula['file']);
             $assets->add($asset);
         }
         return $assets;
     }
     return parent::parseInput($input, $options);
 }
开发者ID:nmariani,项目名称:KnpRadBundle,代码行数:32,代码来源:PipelineAssetFactory.php


示例4: fonts

 public function fonts(array $params)
 {
     $font = $params['font'];
     if (strlen($font) < 1) {
         return false;
     }
     $fontfiles = Registry::getInstance()->assets['fonts'];
     if (isset($fontfiles[$font])) {
         $asset = new FileAsset($fontfiles[$font]);
         switch (strtolower(substr($font, strpos($font, ".")))) {
             case ".eot":
                 $type = "application/vnd.ms-fontobject";
                 break;
             case "otf":
                 $type = "font/opentype";
                 break;
             case "ttf":
                 $type = "application/x-font-ttf";
                 break;
             case ".woff":
                 $type = "application/x-font-woff";
                 break;
             default:
                 $type = "application/x-font";
         }
         header('Content-Type: ' . $type);
         echo $asset->dump();
     }
     return true;
 }
开发者ID:kingboard,项目名称:kingboard,代码行数:30,代码来源:Assetic.php


示例5: testCompassMixin

 public function testCompassMixin()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/compass/compass.sass');
     $asset->load();
     $this->filter->filterLoad($asset);
     $this->assertContains('text-decoration', $asset->getContent());
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:7,代码来源:CompassFilterTest.php


示例6: testCompassExtensionCanBeDisabled

 public function testCompassExtensionCanBeDisabled()
 {
     $this->setExpectedException("Exception", "Undefined mixin box-shadow: failed at `@include box-shadow(10px " . "10px 8px red);` line: 4");
     $asset = new FileAsset(__DIR__ . '/fixtures/sass/main_compass.scss');
     $asset->load();
     $this->getFilter(false)->filterLoad($asset);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:7,代码来源:ScssphpFilterTest.php


示例7: testAssetLastModifiedTimestampIsPrependBeforeFileExtension

 public function testAssetLastModifiedTimestampIsPrependBeforeFileExtension()
 {
     $asset = new FileAsset(TEST_ASSETS_DIR . '/css/global.css');
     $asset->setTargetPath(TEST_PUBLIC_DIR . '/css/global.css');
     $this->cacheBuster->process($asset);
     $this->assertSame(TEST_PUBLIC_DIR . '/css/global.' . $asset->getLastModified() . '.css', $asset->getTargetPath());
 }
开发者ID:supa86000,项目名称:zf2-assetic-module,代码行数:7,代码来源:LastModifiedStrategyTest.php


示例8: testRelativeSourceUrlImportImports

 public function testRelativeSourceUrlImportImports()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/jsmin/js.js');
     $asset->load();
     $filter = new JSMinFilter();
     $filter->filterDump($asset);
     $this->assertEquals('var a="abc";;;var bbb="u";', $asset->getContent());
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:8,代码来源:JSMinFilterTest.php


示例9: testRelativeSourceUrlImportImports

 public function testRelativeSourceUrlImportImports()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/minifycsscompressor/main.css');
     $asset->load();
     $filter = new MinifyCssCompressorFilter();
     $filter->filterDump($asset);
     $this->assertEquals('body{color:white}body{background:black}', $asset->getContent());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:8,代码来源:MinifyCssCompressorFilterTest.php


示例10: testNonCssImport

 public function testNonCssImport()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/cssimport/noncssimport.css', array(), __DIR__ . '/fixtures/cssimport', 'noncssimport.css');
     $asset->load();
     $filter = new CssImportFilter();
     $filter->filterLoad($asset);
     $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/cssimport/noncssimport.css'), $asset->getContent(), '->filterLoad() skips non css');
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:8,代码来源:CssImportFilterTest.php


示例11: createAssetManager

 protected function createAssetManager()
 {
     $asset = new FileAsset(__DIR__ . '/../../../tests/test.css');
     $asset->setTargetPath('css/test.css');
     $assetManager = new AssetManager();
     $assetManager->set('test_css', $asset);
     return $assetManager;
 }
开发者ID:rhysr,项目名称:zf2assetic,代码行数:8,代码来源:AssetPathTest.php


示例12: testRelativeSourceUrlImportImports

 public function testRelativeSourceUrlImportImports()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/jsmin/js.js');
     $asset->load();
     $filter = new JSqueezeFilter();
     $filter->filterDump($asset);
     $this->assertEquals(";var a='abc',bbb='u';", $asset->getContent());
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:8,代码来源:JSqueezeFilterTest.php


示例13: testPacker

 public function testPacker()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/packer/example.js');
     $asset->load();
     $filter = new PackerFilter();
     $filter->filterDump($asset);
     $this->assertEquals("var exampleFunction=function(arg1,arg2){alert('exampleFunction called!')}", $asset->getContent());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:8,代码来源:PackerFilterTest.php


示例14: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $importFilter = $this->importFilter;
     $sourceRoot = $asset->getSourceRoot();
     $sourcePath = $asset->getSourcePath();
     $callback = function ($matches) use($importFilter, $sourceRoot, $sourcePath) {
         if (!$matches['url']) {
             return $matches[0];
         }
         if (null === $sourceRoot) {
             return $matches[0];
         }
         $importRoot = $sourceRoot;
         if (false !== strpos($matches['url'], '://')) {
             // absolute
             list($importScheme, $tmp) = explode('://', $matches['url'], 2);
             list($importHost, $importPath) = explode('/', $tmp, 2);
             $importRoot = $importScheme . '://' . $importHost;
         } elseif (0 === strpos($matches['url'], '//')) {
             // protocol-relative
             list($importHost, $importPath) = explode('/', substr($matches['url'], 2), 2);
             $importHost = '//' . $importHost;
         } elseif ('/' == $matches['url'][0]) {
             // root-relative
             $importPath = substr($matches['url'], 1);
         } elseif (null !== $sourcePath) {
             // document-relative
             $importPath = $matches['url'];
             if ('.' != ($sourceDir = dirname($sourcePath))) {
                 $importPath = $sourceDir . '/' . $importPath;
             }
         } else {
             return $matches[0];
         }
         // ignore other imports
         if ('css' != pathinfo($importPath, PATHINFO_EXTENSION)) {
             return $matches[0];
         }
         $importSource = $importRoot . '/' . $importPath;
         if (false !== strpos($importSource, '://') || 0 === strpos($importSource, '//')) {
             $import = new HttpAsset($importSource, array($importFilter), true);
         } elseif (!file_exists($importSource)) {
             // ignore not found imports
             return $matches[0];
         } else {
             $import = new FileAsset($importSource, array($importFilter), $importRoot, $importPath);
         }
         $import->setTargetPath($sourcePath);
         return $import->dump();
     };
     $content = $asset->getContent();
     $lastHash = md5($content);
     do {
         $content = $this->filterImports($content, $callback);
         $hash = md5($content);
     } while ($lastHash != $hash && ($lastHash = $hash));
     $asset->setContent($content);
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:58,代码来源:CssImportFilter.php


示例15: testCompilation

 public function testCompilation()
 {
     $asset = new FileAsset(__DIR__ . '/stubs/coffeescript/script.coffee');
     $asset->load();
     $filter = new CoffeeScriptphpFilter();
     $filter->filterLoad($asset);
     $expected = file_get_contents(__DIR__ . '/stubs/coffeescript/script.js');
     $this->assertEquals($expected, $asset->getContent());
 }
开发者ID:sohailaammarocs,项目名称:lfc,代码行数:9,代码来源:CoffescriptphpFilterTest.php


示例16: testCssEmbedMhtml

 public function testCssEmbedMhtml()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/cssembed/test.css');
     $asset->load();
     $this->filter->setMhtml(true);
     $this->filter->setMhtmlRoot('/test');
     $this->filter->filterDump($asset);
     $this->assertContains('url(mhtml:/test/!', $asset->getContent());
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:9,代码来源:CssEmbedFilterTest.php


示例17: testFileAsset

 public function testFileAsset()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/handlebars/template.handlebars');
     $asset->load();
     $this->filter->filterLoad($asset);
     $this->assertNotContains('{{ var }}', $asset->getContent());
     $this->assertContains('Ember.TEMPLATES["template"]', $asset->getContent());
     $this->assertContains('data.buffer.push("<div id=\\"test\\"><h2>");', $asset->getContent());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:9,代码来源:EmberPrecompileFilterTest.php


示例18: testMinimizeHandlebars

 public function testMinimizeHandlebars()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/handlebars/template.handlebars');
     $asset->load();
     $this->filter->setMinimize(true);
     $this->filter->filterLoad($asset);
     $this->assertNotContains('{{ var }}', $asset->getContent());
     $this->assertNotContains("\n", $asset->getContent());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:9,代码来源:HandlebarsFilterTest.php


示例19: testRelativeSourceUrlImportImports

 public function testRelativeSourceUrlImportImports()
 {
     $asset = new FileAsset(__DIR__ . '/fixtures/cssmin/main.css');
     $asset->load();
     $filter = new CssMinFilter(__DIR__ . '/fixtures/cssmin');
     $filter->setFilter('ImportImports', true);
     $filter->filterDump($asset);
     $this->assertEquals('body{color:white}body{background:black}', $asset->getContent());
 }
开发者ID:laubosslink,项目名称:lab,代码行数:9,代码来源:CssMinFilterTest.php


示例20: testCssEmbedDataUri

 public function testCssEmbedDataUri()
 {
     $data = base64_encode(file_get_contents(__DIR__ . '/fixtures/home.png'));
     $asset = new FileAsset(__DIR__ . '/fixtures/cssembed/test.css');
     $asset->load();
     $filter = new PhpCssEmbedFilter();
     $filter->filterLoad($asset);
     $this->assertContains('url(data:image/png;base64,' . $data, $asset->getContent());
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:9,代码来源:PhpCssEmbedFilterTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Asset\StringAsset类代码示例发布时间:2022-05-23
下一篇:
PHP Asset\AssetInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap