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


PHP Asset\AssetCollection类代码示例

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


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

示例1: resolve

 /**
  * {@inheritDoc}
  */
 public function resolve($name)
 {
     if (!isset($this->collections[$name])) {
         return null;
     }
     if (!is_array($this->collections[$name])) {
         throw new \RuntimeException("Collection with name {$name} is not an array.");
     }
     $collection = new AssetCollection();
     $mimeType = 'application/javascript';
     $collection->setTargetPath($name);
     foreach ($this->collections[$name] as $asset) {
         if (!is_string($asset)) {
             throw new \RuntimeException('Asset should be of type string. got ' . gettype($asset));
         }
         if (null === ($content = $this->riotTag->__invoke($asset))) {
             throw new \RuntimeException("Riot tag '{$asset}' could not be found.");
         }
         $res = new StringAsset($content);
         $res->mimetype = $mimeType;
         $asset .= ".js";
         $this->getAssetFilterManager()->setFilters($asset, $res);
         $collection->add($res);
     }
     $collection->mimetype = $mimeType;
     return $collection;
 }
开发者ID:prooph,项目名称:link-app-core,代码行数:30,代码来源:RiotTagCollectionResolver.php

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

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

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

示例5: createGroup

 /**
  * Create a new AssetCollection instance for the given group.
  *
  * @param  string                         $name
  * @param  bool                           $overwrite force writing
  * @return \Assetic\Asset\AssetCollection
  */
 public function createGroup($name, $overwrite = false)
 {
     if (isset($this->groups[$name])) {
         return $this->groups[$name];
     }
     $assets = $this->createAssetArray($name);
     $filters = $this->createFilterArray($name);
     $coll = new AssetCollection($assets, $filters);
     if ($output = $this->getConfig($name, 'output')) {
         $coll->setTargetPath($output);
     }
     // check output cache
     $write_output = true;
     if (!$overwrite) {
         if (file_exists($output = public_path($coll->getTargetPath()))) {
             $output_mtime = filemtime($output);
             $asset_mtime = $coll->getLastModified();
             if ($asset_mtime && $output_mtime >= $asset_mtime) {
                 $write_output = false;
             }
         }
     }
     // store assets
     if ($overwrite || $write_output) {
         $writer = new AssetWriter(public_path());
         $writer->writeAsset($coll);
     }
     return $this->groups[$name] = $coll;
 }
开发者ID:slushie,项目名称:laravel-assetic,代码行数:36,代码来源:Asset.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: 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

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

示例9: resolvePlugins

 /**
  * Resolve to the plugins for this module (expand).
  *
  * @throws \SxBootstrap\Exception\RuntimeException
  * @return \Assetic\Asset\AssetCollection
  */
 protected function resolvePlugins()
 {
     $config = $this->config;
     $pluginFiles = $this->getPluginNames($config->getMakeFile());
     $includedPlugins = $config->getIncludedPlugins();
     $excludedPlugins = $config->getExcludedPlugins();
     if (!empty($excludedPlugins) && !empty($includedPlugins)) {
         throw new Exception\RuntimeException('You may not set both excluded and included plugins.');
     }
     $pluginsAsset = new AssetCollection();
     $mimeType = null;
     foreach ($pluginFiles as $plugin) {
         if (!empty($excludedPlugins) && in_array($plugin, $excludedPlugins)) {
             continue;
         } elseif (!empty($includedPlugins) && !in_array($plugin, $includedPlugins)) {
             continue;
         }
         $res = $this->getAggregateResolver()->resolve('js/bootstrap-' . $plugin . '.js');
         if (null === $res) {
             throw new Exception\RuntimeException("Asset '{$plugin}' could not be found.");
         }
         if (!$res instanceof AssetInterface) {
             throw new Exception\RuntimeException("Asset '{$plugin}' does not implement Assetic\\Asset\\AssetInterface.");
         }
         if (null !== $mimeType && $res->mimetype !== $mimeType) {
             throw new Exception\RuntimeException(sprintf('Asset "%s" from collection "%s" doesn\'t have the expected mime-type "%s".', $plugin, $config->getPluginAlias(), $mimeType));
         }
         $mimeType = $res->mimetype;
         $this->getAssetFilterManager()->setFilters($plugin, $res);
         $pluginsAsset->add($res);
     }
     $pluginsAsset->mimetype = $mimeType;
     return $pluginsAsset;
 }
开发者ID:spoonx,项目名称:sxbootstrap,代码行数:40,代码来源:BootstrapResolver.php

示例10: testProcess_withAssetCollection_shouldHash

 public function testProcess_withAssetCollection_shouldHash()
 {
     $collection = new AssetCollection();
     $collection->add($this->getFileAsset('asset.txt'));
     $collection->add($this->getStringAsset('string', 'string.txt'));
     $collection->setTargetPath('collection.txt');
     $this->getCacheBustingWorker()->process($collection, $this->getAssetFactory());
     $this->assertSame('collection-ae851400.txt', $collection->getTargetPath());
 }
开发者ID:jeroenvdheuvel,项目名称:assetic-cache-busting-worker,代码行数:9,代码来源:CacheBustingWorkerTest.php

示例11: build

 public function build($collection_name)
 {
     $build_path_setting = Config::get("assetie::build_path");
     $build_directory = public_path() . DIRECTORY_SEPARATOR . $build_path_setting;
     /**
      * the designated name of the build, i.e. base_123.js
      */
     $build_name = $collection_name . "." . $this->buildExtension;
     $build_file = $build_directory . DIRECTORY_SEPARATOR . $build_name;
     $buildExists = file_exists($build_file);
     $build_url = URL::asset($build_path_setting . DIRECTORY_SEPARATOR . $build_name);
     $debugMode = Config::get("app.debug");
     if (!$buildExists || $debugMode) {
         $files = \Collection::dump($collection_name)[$this->group];
         $collection_hash = sha1(serialize($files));
         $hash_in_cache = Cache::get("collection_" . $this->group . "_" . $collection_name);
         $collectionChanged = $collection_hash != $hash_in_cache;
         $src_dir = app_path() . DIRECTORY_SEPARATOR . Config::get("assetie::directories." . $this->group) . DIRECTORY_SEPARATOR;
         $forceRebuild = false;
         if ($collectionChanged) {
             $forceRebuild = true;
         } else {
             if ($buildExists) {
                 /**
                  * only recompile if no compiled build exists or when in debug mode and
                  * build's source files or collections.php has been changed
                  */
                 $forceRebuild = $this->checkModification($build_file, $files, $src_dir);
             }
         }
         if (!$buildExists || $forceRebuild) {
             $am = new AssetManager();
             $assets = [];
             foreach ($files as $file) {
                 $filters = $this->getFilters($file);
                 $assets[] = new FileAsset($src_dir . $file, $filters);
             }
             $collection = new AssetCollection($assets);
             // , $filters
             $collection->setTargetPath($build_name);
             $am->set('collection', $collection);
             $writer = new AssetWriter($build_directory);
             $writer->writeManagerAssets($am);
         }
         // Cache::forever("collection_" . $collection_name, $collection_hash);
         $cache_key = "collection_" . $this->group . "_" . $collection_name;
         if (Cache::has($cache_key) && $collectionChanged) {
             Cache::forget($cache_key);
         }
         if ($collectionChanged) {
             Cache::put($cache_key, $collection_hash, 60);
             // 1 hour
         }
     }
     return $build_url;
 }
开发者ID:dhardtke,项目名称:assetie,代码行数:56,代码来源:AssetBuilder.php

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

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

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

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


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