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


PHP AssetCollection::ensureFilter方法代码示例

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


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

示例1: generateContent

 protected function generateContent($templatePath, $contentType)
 {
     // We build these into a single string so that we can deploy this resume as a
     // single file.
     $assetPath = join(DIRECTORY_SEPARATOR, array($templatePath, $contentType));
     if (!file_exists($assetPath)) {
         return '';
     }
     $assets = array();
     // Our PHAR deployment can't handle the GlobAsset typically used here
     foreach (new \DirectoryIterator($assetPath) as $fileInfo) {
         if ($fileInfo->isDot() || !$fileInfo->isFile()) {
             continue;
         }
         array_push($assets, new FileAsset($fileInfo->getPathname()));
     }
     usort($assets, function (FileAsset $a, FileAsset $b) {
         return strcmp($a->getSourcePath(), $b->getSourcePath());
     });
     $collection = new AssetCollection($assets);
     switch ($contentType) {
         case 'css':
             $collection->ensureFilter(new Filter\LessphpFilter());
             break;
     }
     return $collection->dump();
 }
开发者ID:regothic,项目名称:markdown-resume,代码行数:27,代码来源:HtmlCommand.php

示例2: addCollection

 public function addCollection($name, $assets)
 {
     $collection = new AssetCollection(array_map(function ($asset) {
         return new FileAsset($this->guessPath($asset['src']));
     }, $assets));
     $collection->setTargetPath($name);
     if (endsWith($name, '.css')) {
         $collection->ensureFilter(new CssRewriteFilter());
     }
     $this->write($name, $collection->dump());
 }
开发者ID:elolli,项目名称:DreamItReelProductions-Website,代码行数:11,代码来源:AssetsCompiler.php

示例3: testDefault

 public function testDefault()
 {
     $asset = __DIR__ . "/../../resources/test.coffee";
     $assetCollection = new AssetCollection();
     $assetCollection->add(new FileAsset($asset));
     $assetCollection->ensureFilter(new CoffeeScriptPhpFilter());
     $ret = $assetCollection->dump();
     $exp = "var MyClass, myObject;";
     $this->assertRegExp("/{$exp}/", $ret);
     $exp = "Generated by CoffeeScript PHP";
     $this->assertRegExp("/{$exp}/", $ret);
 }
开发者ID:kohkimakimoto,项目名称:assetic-extension,代码行数:12,代码来源:CoffeeScriptPhpFilterTest.php

示例4: testIterationFilters

 public function testIterationFilters()
 {
     $count = 0;
     $filter = new CallablesFilter(function () use(&$count) {
         ++$count;
     });
     $coll = new AssetCollection();
     $coll->add(new StringAsset(''));
     $coll->ensureFilter($filter);
     foreach ($coll as $asset) {
         $asset->dump();
     }
     $this->assertEquals(1, $count, 'collection filters are called when child assets are iterated over');
 }
开发者ID:richardmiller,项目名称:assetic,代码行数:14,代码来源:AssetCollectionTest.php

示例5: newAssetCollection

 /**
  * @return AssetCollection
  */
 protected function newAssetCollection()
 {
     // Aggregate all the assets into one file.
     $assets = new AssetCollection();
     if ($this->config->has('component-scriptFilters')) {
         $filters = $this->config->get('component-scriptFilters');
         if (isset($filters) && is_array($filters)) {
             foreach ($filters as $filter => $filterParams) {
                 $reflection = new \ReflectionClass($filter);
                 /** @var \Assetic\Filter\FilterInterface $filter */
                 $filter = $reflection->newInstanceArgs($filterParams);
                 $assets->ensureFilter($filter);
             }
         }
     }
     return $assets;
 }
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:20,代码来源:RequireJsProcess.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = $this->getContainer();
     $filesystem = $container->get('filesystem');
     $languages = $container->getParameter('hatimeria_ext_js.locales');
     $files = $container->getParameter('hatimeria_ext_js.compiled_files');
     $domains = $container->getParameter("hatimeria_ext_js.translation_domains");
     $vendorPath = $container->getParameter("hatimeria_ext_js.javascript_vendor_path");
     $hdefault = new JavascriptController();
     $hdefault->setContainer($container);
     $dynamic = $hdefault->dynamicAction()->getContent();
     $hdirect = new DirectController();
     $hdirect->setContainer($container);
     $api = $hdirect->getApiAction()->getContent();
     $expose = $container->get('bazinga.exposetranslation.controller');
     $routing = $container->get('fos_js_routing.controller');
     $compressor = new JsCompressorFilter('vendor/bundles/Hatimeria/ExtJSBundle/Resources/jar/yuicompressor.jar');
     $extjs = "web/bundles/hatimeriaextjs/js/extjs/";
     // @todo recursive glob
     foreach ($languages as $lang) {
         $ac = new AssetCollection();
         $ac->add(new FileAsset("web/" . $vendorPath . "/ext-all.js"));
         $ac->add(new FileAsset($extjs . "/core/overrides.js"));
         $ac->add(new StringAsset($dynamic));
         $ac->add(new FileAsset($extjs . "/translation/Translation.js"));
         foreach ($domains as $domain) {
             $ac->add(new StringAsset($expose->exposeTranslationAction($domain, $lang, 'js')->getContent()));
         }
         $ac->add(new FileAsset("web/" . $vendorPath . "locale/ext-lang-" . $lang . ".js"));
         $ac->add(new FileAsset($extjs . "/core/direct-api-handler.js"));
         $ac->add(new FileAsset($extjs . "/routing/Routing.js"));
         $ac->add(new GlobAsset($extjs . "/core/utils/*"));
         $ac->add(new GlobAsset($extjs . "/core/mixins/*"));
         $ac->add(new GlobAsset($extjs . "/core/store/*"));
         $ac->add(new GlobAsset($extjs . "/core/model/*"));
         $ac->add(new GlobAsset($extjs . "/core/grid/*"));
         $ac->add(new GlobAsset($extjs . "/core/response/*"));
         $ac->add(new GlobAsset($extjs . "/core/window/*"));
         $ac->add(new FileAsset($extjs . "/core/form/BaseForm.js"));
         $ac->add(new GlobAsset($extjs . "/core/form/*"));
         $ac->add(new GlobAsset($extjs . "/core/field/*"));
         $ac->add(new GlobAsset($extjs . "/core/user/*"));
         $ac->add(new GlobAsset($extjs . "/treeselect/store/*"));
         $ac->add(new GlobAsset($extjs . "/treeselect/panel/*"));
         $ac->add(new GlobAsset($extjs . "/treeselect/field/*"));
         $ac->add(new StringAsset($api));
         $ac->add(new StringAsset($routing->indexAction('js')->getContent()));
         foreach ($files as $file) {
             $ac->add(new FileAsset('web/' . $file));
         }
         $ac->ensureFilter($compressor);
         $compiled = $ac->dump();
         @mkdir('web/compiled/js', 0755, true);
         file_put_contents(sprintf("web/compiled/js/ext-%s.js", $lang), $compiled);
     }
     $output->writeln('Assets compiled');
 }
开发者ID:Borales,项目名称:HatimeriaExtJSBundle,代码行数:57,代码来源:AssetsCompileCommand.php

示例7: testClearingFiltersWorksAfterCollectionHasBeenIterated

 public function testClearingFiltersWorksAfterCollectionHasBeenIterated()
 {
     $coll = new AssetCollection();
     $coll->add(new StringAsset(""));
     $coll->ensureFilter(new CallablesFilter());
     /* This iteration is necessary to internally prime the collection's
        "clones" with one filter. */
     foreach ($coll as $asset) {
         $this->assertCount(1, $asset->getFilters());
     }
     $coll->clearFilters();
     foreach ($coll as $asset) {
         $this->assertCount(0, $asset->getFilters());
     }
 }
开发者ID:selimcr,项目名称:servigases,代码行数:15,代码来源:AssetCollectionTest.php

示例8: compile

 /**
  * Eejecuta la rutina de minificacion
  * 
  * Los tipos de recursos aceptados son:
  * Resources:CSS
  * Resources:JS
  * Resources:NONE
  * 
  * @param int $compile El tipo de recurso a minificar
  */
 public function compile($compile = Resources::NONE)
 {
     require_once __DIR__ . '/cssmin-v3.0.1.php';
     require_once __DIR__ . '/jsmin.php';
     $asset = new AssetCollection();
     $this->resources->each(function ($key, $value) use(&$asset) {
         if ($value->flag) {
             $asset->add(new FileAsset($value->asset));
         } else {
             $asset->add(new GlobAsset($value->asset));
         }
     });
     if ($compile == Resources::JS) {
         $asset->ensureFilter(new \Assetic\Filter\JSMinFilter());
     }
     if ($compile == Resources::CSS) {
         $asset->ensureFilter(new \Assetic\Filter\CssMinFilter());
     }
     // the code is merged when the asset is dumped
     $bundles = \Raptor\Core\Location::get('web_bundles');
     if (!file_exists($bundles . $this->bundleName)) {
         mkdir($bundles . $this->bundleName, 0777, true);
     }
     if ($this->name[0] == '/' or $this->name[0] == DIRECTORY_SEPARATOR) {
         unset($this->name[0]);
     }
     $dir = dirname($bundles . $this->bundleName . '/' . $this->name);
     if (!file_exists($dir)) {
         mkdir($dir, 0777, true);
     }
     if ($this->force == true) {
         file_put_contents($bundles . $this->bundleName . '/' . $this->name, $asset->dump());
     } else {
         if (!file_exists($bundles . $this->bundleName . '/' . $this->name)) {
             file_put_contents($bundles . $this->bundleName . '/' . $this->name, $asset->dump());
         }
     }
 }
开发者ID:williamamed,项目名称:Raptor2,代码行数:48,代码来源:AssetCompiler.php


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