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


PHP AssetCollection::dump方法代码示例

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


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

示例1: testMinifyCss

 public function testMinifyCss()
 {
     $assets = array(new FileAsset(TEST_PATH . 'dummy.css'));
     $filters = array(new MinFilter('css'));
     $collection = new AssetCollection($assets, $filters);
     $this->assertEquals('.foo{display:block}', $collection->dump());
 }
开发者ID:toopay,项目名称:assetic-minifier,代码行数:7,代码来源:MinFilterTest.php

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

示例3: dump

 /**
  * {@inheritdoc}
  */
 public function dump(FilterInterface $additionalFilter = null)
 {
     if (!$this->loaded) {
         $this->loadResourcesFromRepo();
     }
     return parent::dump($additionalFilter);
 }
开发者ID:puli,项目名称:assetic-extension,代码行数:10,代码来源:PuliGlobAsset.php

示例4: dump

 public function dump(FilterInterface $additionalFilter = null)
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     return parent::dump($additionalFilter);
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:7,代码来源:GlobAsset.php

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

示例6: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $content = "";
     $files = array();
     $extraFiles = array();
     $absolutePath = $asset->getSourceRoot() . '/' . $asset->getSourcePath();
     $this->parser->mime = $this->parser->mimeType($absolutePath);
     if ($this->parser->mime === 'javascripts') {
         $extraFiles = $this->parser->get("javascript_files", array());
     }
     if ($this->parser->mime === 'stylesheets') {
         $extraFiles = $this->parser->get("stylesheet_files", array());
     }
     $absoluteFilePaths = $this->parser->getFilesArrayFromDirectives($absolutePath);
     if ($absoluteFilePaths) {
         $absoluteFilePaths = $extraFiles + $absoluteFilePaths;
     }
     foreach ($absoluteFilePaths as $absoluteFilePath) {
         $files[] = $this->generator->file($absoluteFilePath, false);
     }
     if (!$absoluteFilePaths) {
         $files[] = $this->generator->file($absolutePath, false);
     }
     $global_filters = $this->parser->get("sprockets_filters.{$this->parser->mime}", array());
     $collection = new AssetCollection($files, $global_filters);
     $asset->setContent($collection->dump());
 }
开发者ID:yashb,项目名称:generator,代码行数:27,代码来源:SprocketsFilter.php

示例7: runResolve

 public function runResolve(framework\Request $request)
 {
     $theme = isset($request['theme_name']) ? $request['theme_name'] : framework\Settings::getThemeName();
     if ($request->hasParameter('css')) {
         $this->getResponse()->setContentType('text/css');
         if (!$request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'css';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'css' . DS . $request->getParameter('css');
         } else {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'css' . DS . $request->getParameter('css');
         }
     } elseif ($request->hasParameter('js')) {
         $this->getResponse()->setContentType('text/javascript');
         if ($request->hasParameter('theme_name')) {
             $basepath = THEBUGGENIE_PATH . 'themes';
             $asset = THEBUGGENIE_PATH . 'themes' . DS . $theme . DS . 'js' . DS . $request->getParameter('js');
         } elseif ($request->hasParameter('module_name') && framework\Context::isModuleLoaded($request['module_name'])) {
             $module_path = framework\Context::isInternalModule($request['module_name']) ? THEBUGGENIE_INTERNAL_MODULES_PATH : THEBUGGENIE_MODULES_PATH;
             $basepath = $module_path . $request['module_name'] . DS . 'public' . DS . 'js';
             $asset = $module_path . $request['module_name'] . DS . 'public' . DS . 'js' . DS . $request->getParameter('js');
         } else {
             $basepath = THEBUGGENIE_PATH . 'public' . DS . 'js';
             $asset = THEBUGGENIE_PATH . 'public' . DS . 'js' . DS . $request->getParameter('js');
         }
     } else {
         throw new \Exception('The expected theme Asset type is not supported.');
     }
     $fileAsset = new AssetCollection(array(new FileAsset($asset, array(), $basepath)));
     $fileAsset->load();
     // Do not decorate the asset with the theme's header/footer
     $this->getResponse()->setDecoration(framework\Response::DECORATE_NONE);
     return $this->renderText($fileAsset->dump());
 }
开发者ID:AzerothShard,项目名称:thebuggenie,代码行数:34,代码来源:Asset.php

示例8: stylesheets

 /**
  * Dumps out the stylesheets for this file
  * 
  * If we should concat then this should probably be a 
  * manifest file so we should process directives inside
  * 
  * @param  [type] $path [description]
  * @return [type]       [description]
  */
 public function stylesheets($path)
 {
     $filters = array();
     $files = array($this->getFullPath($path, 'stylesheets'));
     if ($this->shouldConcat()) {
         $files = $this->directives->getFilesFrom($this->getFullPath($path, 'stylesheets'));
     }
     $styles = new AssetCollection($this->getStyleAssets($files), $filters);
     return $styles->dump();
 }
开发者ID:jaymondigo,项目名称:custommade,代码行数:19,代码来源:SprocketsRepository.php

示例9: dump

 public function dump()
 {
     $file = array(new FileAsset($this->file));
     $this->set_type_filter($this->type);
     if ($this->config->minify) {
         $this->set_minify_filter($this->type);
     }
     $result = new AssetCollection($file, $this->filters);
     return $result->dump();
 }
开发者ID:josephj,项目名称:assetla,代码行数:10,代码来源:AssetlaFile.php

示例10: testOne

 public function testOne()
 {
     $uglify = new UglifyJs2Filter("/usr/bin/uglifyjs", "/usr/bin/node");
     $uglify->setCompress(true);
     $uglify->setMangle(true);
     $uglify->setCompress(true);
     $js = new AssetCollection(array(new GlobAsset(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "assets/src/*", array($uglify))));
     echo $js->dump();
     echo PHP_EOL;
 }
开发者ID:jeanpasqualini-lesson,项目名称:lesson-assetic,代码行数:10,代码来源:MainTest.php

示例11: createVersion

 public function createVersion($request, $componentData, $component, $versionType = false, $branch = 'master')
 {
     $em = $this->_em;
     /**
      * manage versionType name
      * 
      * If is additional branch add brnach name at end.
      */
     if ($branch != 'master' && $branch != false) {
         if ($versionType) {
             $versionType = $versionType . '-' . $branch;
         } else {
             $versionType = $componentData['version']['value'] . '-' . $branch;
         }
     } else {
         if ($versionType) {
             $versionType = $versionType;
         } else {
             $versionType = $componentData['version']['value'];
         }
     }
     if (!$versionType) {
         $version = new \FWM\CraftyComponentsBundle\Entity\Versions();
         $version->setValue($versionType);
     } else {
         $componentData['version']['value'] = $versionType;
         $version = $em->getRepository('FWMCraftyComponentsBundle:Versions')->findOneBy(array('component' => $component->getId(), 'value' => $versionType));
         if (!$version) {
             $version = new \FWM\CraftyComponentsBundle\Entity\Versions();
             $version->setValue($versionType);
         }
     }
     $version->setSha($componentData['version']['sha']);
     $version->setComponent($component);
     $version->setFileContent($componentData['componentFilesValue']);
     $version->setCreatedAt(new \DateTime());
     //complete all files
     foreach (ArrayService::objectToArray(json_decode($componentData['componentFilesValue'])) as $value) {
         $tempFileContent[] = base64_decode($value);
     }
     $file = implode(' ', $tempFileContent);
     $path = $request->server->get('DOCUMENT_ROOT') . '/uploads/components/' . strtolower($componentData['name']) . '-' . strtolower($versionType);
     //create uncompressed version
     file_put_contents($path . '-uncompressed.js', $file);
     //minify uncompressed version
     try {
         $js = new AssetCollection(array(new FileAsset($path . '-uncompressed.js')), array(new Yui\JsCompressorFilter($request->server->get('DOCUMENT_ROOT') . '/../app/Resources/java/yuicompressor.jar')));
         $minifidedFile = $js->dump();
     } catch (\Exception $e) {
         $minifidedFile = $file;
     }
     // create minified version
     file_put_contents($path . '.js', $minifidedFile);
     return $version;
 }
开发者ID:radzikowski,项目名称:CraftyComponents,代码行数:55,代码来源:VersionsRepository.php

示例12: jsPackAction

 public function jsPackAction()
 {
     $collection = new AssetCollection();
     foreach ($this->container->getParameter('cms.cms_resources.js_pack') as $asset) {
         $collection->add(new FileAsset($asset));
     }
     $content = $this->container->getCache()->fetch('cms_assets', 'js_pack', function () use($collection) {
         return $collection->dump();
     }, $collection->getLastModified());
     return new Response($content, 200, array('Content-Type' => 'text/javascript'));
 }
开发者ID:sitesupra,项目名称:sitesupra,代码行数:11,代码来源:ResourceController.php

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

示例14: process

 /**
  * {@inheritdoc}
  */
 public function process()
 {
     $filters = array(new CssRewriteFilter());
     if ($this->config->has('component-styleFilters')) {
         $customFilters = $this->config->get('component-styleFilters');
         if (isset($customFilters) && is_array($customFilters)) {
             foreach ($customFilters as $filter => $filterParams) {
                 $reflection = new \ReflectionClass($filter);
                 $filters[] = $reflection->newInstanceArgs($filterParams);
             }
         }
     }
     $filterCollection = new FilterCollection($filters);
     $assets = new AssetCollection();
     $styles = $this->packageStyles($this->packages);
     foreach ($styles as $package => $packageStyles) {
         $packageAssets = new AssetCollection();
         $packagePath = $this->componentDir . '/' . $package;
         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;
                 //Replace glob patterns with filenames.
                 $filename = basename($style);
                 if (preg_match('~^\\*(\\.[^\\.]+)$~', $filename, $matches)) {
                     $sourcePath = str_replace($filename, basename($assetPath), $sourcePath);
                 }
                 // Where the final CSS will be generated.
                 $targetPath = $this->componentDir;
                 // Build the asset and add it to the collection.
                 $asset = new FileAsset($assetPath, $filterCollection, $sourceRoot, $sourcePath);
                 $asset->setTargetPath($targetPath);
                 $assets->add($asset);
                 // Add asset to package collection.
                 $sourcePath = preg_replace('{^.*' . preg_quote($package) . '/}', '', $sourcePath);
                 $asset = new FileAsset($assetPath, $filterCollection, $sourceRoot, $sourcePath);
                 $asset->setTargetPath($packagePath);
                 $packageAssets->add($asset);
             }
         }
         if (file_put_contents($packagePath . '/' . $package . '-built.css', $packageAssets->dump()) === FALSE) {
             $this->io->write("<error>Error writing {$package}-built.css to destination</error>");
         }
     }
     if (file_put_contents($this->componentDir . '/require.css', $assets->dump()) === FALSE) {
         $this->io->write('<error>Error writing require.css to destination</error>');
         return false;
     }
     return null;
 }
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:57,代码来源:RequireCssProcess.php

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


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