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

PHP Factory\AssetFactory类代码示例

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

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



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

示例1: getAsseticFactory

 protected function getAsseticFactory()
 {
     if (empty($this->config["input_path"][0])) {
         throw new \Exception('Empty input path');
     }
     $factory = new AssetFactory($this->config["input_path"][0], $this->config["debug"]);
     $factory->setDefaultOutput("");
     // add a FilterManager to the AssetFactory
     $fm = new FilterManager();
     $factory->setFilterManager($fm);
     // adding some filters to the filter manager
     if ($this->config["less_filter"]) {
         $lessphpFilter = new LessphpFilter();
         if ($this->lessPresets) {
             $lessphpFilter->setPresets($this->lessPresets);
         }
         $fm->set("less", $lessphpFilter);
     }
     if ($this->config["scss_filter"]) {
         $scssFilter = new ScssphpFilter();
         $fm->set("scss", $scssFilter);
     }
     $fm->set("min", new CssMinFilter());
     return $factory;
 }
开发者ID:sugiphp,项目名称:assets,代码行数:25,代码来源:CssPacker.php


示例2: getMinifiedAsset

 private function getMinifiedAsset()
 {
     if (!(new SplFileInfo($this->asset->getPath()))->isWritable()) {
         throw new Exception("path " . $this->asset->getPath() . " is not writable");
     }
     $factory = new AssetFactory($this->asset->getPath());
     $factory->addWorker(new CacheBustingWorker());
     $factory->setDefaultOutput('*');
     $fm = new FilterManager();
     $fm->set('min', $this->filter);
     $factory->setFilterManager($fm);
     $asset = $factory->createAsset(call_user_func(function ($files) {
         $r = [];
         foreach ($files as $file) {
             $r[] = $file['fs'];
         }
         return $r;
     }, $this->files), ['min'], ['name' => $this->asset->getBasename()]);
     // only write the asset file if it does not already exist..
     if (!file_exists($this->asset->getPath() . DIRECTORY_SEPARATOR . $asset->getTargetPath())) {
         $writer = new AssetWriter($this->asset->getPath());
         $writer->writeAsset($asset);
         // TODO: write some code to garbage collect files of a certain age?
         // possible alternative, modify CacheBustingWorker to have option
         // to append a timestamp instead of a hash
     }
     return $asset;
 }
开发者ID:evalok,项目名称:php-assetify,代码行数:28,代码来源:Minifier.php


示例3: testNoFilterManager

    public function testNoFilterManager()
    {
        $this->setExpectedException('LogicException', 'There is no filter manager.');

        $factory = new AssetFactory('.');
        $factory->createAsset(array('foo'), array('foo'));
    }
开发者ID:naderman,项目名称:assetic,代码行数:7,代码来源:AssetFactoryTest.php


示例4: getChildren

 public function getChildren(AssetFactory $factory, $content, $loadPath = null)
 {
     $children = array();
     $includePaths = $this->includePaths;
     if (null !== $loadPath && !in_array($loadPath, $includePaths)) {
         array_unshift($includePaths, $loadPath);
     }
     if (empty($includePaths)) {
         return $children;
     }
     foreach (CssUtils::extractImports($content) as $reference) {
         if ('.css' === substr($reference, -4)) {
             continue;
         }
         // the reference may or may not have an extension or be a partial
         if (pathinfo($reference, PATHINFO_EXTENSION)) {
             $needles = array($reference, $this->partialize($reference));
         } else {
             $needles = array($reference . '.scss', $this->partialize($reference) . '.scss');
         }
         foreach ($includePaths as $includePath) {
             foreach ($needles as $needle) {
                 if (file_exists($file = $includePath . '/' . $needle)) {
                     $child = $factory->createAsset($file, array(), array('root' => $includePath));
                     $children[] = $child;
                     $child->load();
                     $children = array_merge($children, $this->getChildren($factory, $child->getContent(), $includePath));
                 }
             }
         }
     }
     return $children;
 }
开发者ID:theaxel,项目名称:assetic,代码行数:33,代码来源:SassphpFilter.php


示例5: __construct

 /**
  * Constructor
  * 
  * @param AssetFactory   $factory The AssetFactory 
  * @param CacheInterface $cache   The Cache Manager
  * @param AssetManager   $manager The Asset Manager
  * 
  * @return void 
  */
 public function __construct(AssetFactory $factory = null, CacheInterface $cache = null, $cacheDir = null, AssetManager $manager = null)
 {
     $this->factory = $factory;
     $this->manager = $manager;
     $this->cache = $cache;
     $this->cacheDirectory = $cacheDir;
     $this->factory->setAssetManager($this->getAssetManager());
 }
开发者ID:nitronet,项目名称:fwk-assetic,代码行数:17,代码来源:AssetsService.php


示例6: getChildren

 public function getChildren(AssetFactory $factory, $content, $loadPath = null)
 {
     $hash = md5($content);
     if ($this->cache->has($hash)) {
         return $factory->createAsset($this->cache->get($hash), array(), array('root' => $loadPath));
     } else {
         return parent::getChildren($factory, $content, $loadPath);
     }
 }
开发者ID:webuni,项目名称:assetic-bundle,代码行数:9,代码来源:LessphpFilter.php


示例7: getAssetFactory

 /**
  * @param $rootPath
  * @param $debug
  * @return AssetFactory
  */
 private function getAssetFactory($rootPath, $debug)
 {
     $filterManager = new FilterManager();
     $filterManager->set('yui_js', new JsCompressorFilter(dirname(__DIR__) . '/../optimizers/yuicompressor/yuicompressor-2.4.7.jar'));
     $assetFactory = new AssetFactory($rootPath, $debug);
     $assetFactory->setFilterManager($filterManager);
     $assetFactory->setAssetManager(new AssetManager());
     return $assetFactory;
 }
开发者ID:eberhm,项目名称:phoenix,代码行数:14,代码来源:Optimizer.php


示例8: process

 public function process(AssetInterface $asset, AssetFactory $factory)
 {
     $path = $asset->getTargetPath();
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     $lastModified = $factory->getLastModified($asset);
     if (null !== $lastModified) {
         $path = substr_replace($path, "{$lastModified}.{$ext}", -1 * strlen($ext));
         $asset->setTargetPath($path);
     }
 }
开发者ID:widmogrod,项目名称:zf2-assetic-module,代码行数:10,代码来源:LastModifiedStrategy.php


示例9: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->basePath = $input->getArgument('write_to') ?: $this->getConfig()->getWebBasePath();
     $this->verbose = $input->getOption('verbose');
     $assetFactory = new AssetFactory($this->getConfig()->getAssetsBasePath(), $this->getConfig()->isDebug());
     $loader = new TwigFormulaLoader($this->twig());
     $this->am = new LazyAssetManager($assetFactory);
     $assetFactory->setAssetManager($this->am);
     $this->am->setLoader('twig', $loader);
 }
开发者ID:NaszvadiG,项目名称:codeigniter-extended,代码行数:10,代码来源:DumpCommand.php


示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->am = $this->getMock('Assetic\\AssetManager');
     $this->fm = $this->getMock('Assetic\\FilterManager');
     $factory = new AssetFactory(__DIR__ . '/templates');
     $factory->setAssetManager($this->am);
     $factory->setFilterManager($this->fm);
     $this->engine->addExtension(new AsseticExtensionForTest($factory));
     $this->loader = new SmartyFormulaLoader($this->engine);
 }
开发者ID:Danack,项目名称:SmartyBundle,代码行数:11,代码来源:SmartyFormulaLoaderTest.php


示例11: factoryAf

 protected function factoryAf()
 {
     $uglify = new UglifyJs2Filter("/usr/bin/uglifyjs", "/usr/bin/node");
     $uglify->setCompress(true);
     $uglify->setMangle(true);
     $uglify->setCompress(true);
     $factory = new AssetFactory(__DIR__ . "/../");
     $filterManager = new FilterManager();
     $filterManager->set("uglify", $uglify);
     $factory->setFilterManager($filterManager);
     return $factory;
 }
开发者ID:jeanpasqualini-lesson,项目名称:lesson-assetic,代码行数:12,代码来源:MainTest.php


示例12: getHash

 protected function getHash(AssetInterface $asset, AssetFactory $factory)
 {
     $hash = hash_init('sha1');
     hash_update($hash, $factory->getLastModified($asset));
     if ($asset instanceof AssetCollectionInterface) {
         foreach ($asset as $i => $leaf) {
             $sourcePath = $leaf->getSourcePath();
             hash_update($hash, $sourcePath ?: $i);
         }
     }
     return substr(hash_final($hash), 0, 7);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:12,代码来源:CacheBustingWorker.php


示例13: build

 /**
  * Builds the AssetFactory object
  *
  * @return \Assetic\Factory\AssetFactory
  */
 public function build()
 {
     $assetManager = new AssetManager();
     $filterManager = new FilterManager();
     foreach ($this->filters as $filterName => $filter) {
         $filterManager->set($filterName, $filter);
     }
     $assetsFactory = new AssetFactory($this->configurationHandler->webDir());
     $assetsFactory->setAssetManager($assetManager);
     $assetsFactory->setFilterManager($filterManager);
     return $assetsFactory;
 }
开发者ID:redkite-labs,项目名称:redkitecms-framework,代码行数:17,代码来源:AsseticFactoryBuilder.php


示例14: configureAssetTools

 protected function configureAssetTools()
 {
     $fm = new FilterManager();
     $fm->set('less', new LessphpFilter());
     $fm->set('cssrewrite', new AssetCssUriRewriteFilter());
     $fm->set('cssmin', new CssMinFilter());
     $fm->set('jscompile', new CompilerApiFilter());
     //$fm->set('jscompilejar', new CompilerJarFilter(storage_path('jar/compiler.jar')));
     $factory = new AssetFactory(Config::get('asset-manager::asset.paths.asset_path'));
     $factory->setFilterManager($fm);
     $factory->setDebug(Config::get('app.debug'));
     $this->assetFactory = $factory;
 }
开发者ID:dustingraham,项目名称:asset-manager,代码行数:13,代码来源:AssetCompiler.php


示例15: getAsseticFactory

 protected function getAsseticFactory()
 {
     if (empty($this->config["input_path"][0])) {
         throw new \Exception("Empty input path");
     }
     $factory = new AssetFactory($this->config["input_path"][0], $this->config["debug"]);
     $factory->setDefaultOutput("");
     // add a FilterManager to the AssetFactory
     $fm = new FilterManager();
     $factory->setFilterManager($fm);
     $fm->set("jshrink", new JShrinkFilter());
     return $factory;
 }
开发者ID:sugiphp,项目名称:assets,代码行数:13,代码来源:JsPacker.php


示例16: renderThemeAssets

 public function renderThemeAssets()
 {
     $conf = (array) $this->getThemeAssets();
     $factory = new Factory\AssetFactory($conf['root_path']);
     $factory->setAssetManager($this->getAssetManager());
     $factory->setFilterManager($this->getFilterManager());
     $factory->setDebug($this->configuration->isDebug());
     $mobileDetect = $this->serviceManager->get('dxMobileDetect');
     $isTablet = $mobileDetect->isTablet();
     $assetName = 'assets';
     $filterName = 'filters';
     $optionName = 'options';
     $outputName = 'output';
     if ($mobileDetect->isMobile()) {
         $assetName = $assetName . 'Mobile';
         $filterName = $filterName . 'Mobile';
         $optionName = $optionName . 'Mobile';
         $outputName = $outputName . 'Mobile';
     }
     if ($mobileDetect->isTablet()) {
         $assetName = $assetName . 'Tablet';
         $filterName = $filterName . 'Tablet';
         $optionName = $optionName . 'Tablet';
         $outputName = $outputName . 'Mobile';
     }
     $collections = (array) $conf['collections'];
     foreach ($collections as $name => $options) {
         $assets = isset($options[$assetName]) ? $options[$assetName] : isset($options['assets']) ? $options['assets'] : array();
         $filtersx = isset($options[$filterName]) ? $options[$filterName] : isset($options['filters']) ? $options['filters'] : array();
         $options = isset($options[$optionName]) ? $options[$optionName] : isset($options['options']) ? $options['options'] : array();
         $options['output'] = isset($options[$outputName]) ? $options[$outputName] : isset($options['output']) ? $options['output'] : $name;
         $filters = $this->initFilters($filtersx);
         /** @var $asset \Assetic\Asset\AssetCollection */
         $asset = $factory->createAsset($assets, $filters, $options);
         # allow to move all files 1:1 to new directory
         # its particulary usefull when this assets are images.
         if (isset($options['move_raw']) && $options['move_raw']) {
             foreach ($asset as $key => $value) {
                 $name = md5($value->getSourceRoot() . $value->getSourcePath());
                 $value->setTargetPath($value->getSourcePath());
                 $value = $this->cache($value);
                 $this->assetManager->set($name, $value);
             }
         } else {
             $asset = $this->cache($asset);
             $this->assetManager->set($name, $asset);
         }
     }
     $writer = new AssetWriter($this->configuration->getWebPath());
     $writer->writeManagerAssets($this->assetManager);
 }
开发者ID:dennesabing,项目名称:dxapp,代码行数:51,代码来源:ThemeAssets.php


示例17: setUp

 protected function setUp()
 {
     if (!class_exists('Twig_Environment')) {
         $this->markTestSkipped('Twig is not installed.');
     }
     $this->am = $this->getMock('Assetic\\AssetManager');
     $this->fm = $this->getMock('Assetic\\FilterManager');
     $factory = new AssetFactory(__DIR__ . '/templates');
     $factory->setAssetManager($this->am);
     $factory->setFilterManager($this->fm);
     $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'));
     $twig->addExtension(new AsseticExtension($factory, array('some_func' => array('filter' => 'some_filter', 'options' => array('output' => 'css/*.css')))));
     $this->loader = new TwigFormulaLoader($twig);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:14,代码来源:TwigFormulaLoaderTest.php


示例18: setUp

 protected function setUp()
 {
     if (!class_exists('Twig_Environment')) {
         $this->markTestSkipped('Twig is not installed.');
     }
     $this->am = $this->getMock('Assetic\\AssetManager');
     $this->fm = $this->getMock('Assetic\\FilterManager');
     $this->valueSupplier = $this->getMock('Assetic\\ValueSupplierInterface');
     $this->factory = new AssetFactory(__DIR__ . '/templates');
     $this->factory->setAssetManager($this->am);
     $this->factory->setFilterManager($this->fm);
     $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem(__DIR__ . '/templates'));
     $this->twig->addExtension(new AsseticExtension($this->factory, array(), $this->valueSupplier));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:14,代码来源:AsseticExtensionTest.php


示例19: init

 /**
  * {@inheritDoc}
  */
 public function init(Application $app)
 {
     $app['assets'] = $app->share(function () use($app) {
         $assetManager = new AssetManager();
         $filterManager = new FilterManager();
         $filterManager->set('less', new LessphpFilter());
         $filterManager->set('cssmin', new CssMinFilter());
         $filterManager->set('jsmin', new JSqueezeFilter());
         $factory = new AssetFactory($app['assets.path']);
         $factory->setAssetManager($assetManager);
         $factory->setFilterManager($filterManager);
         $factory->setDefaultOutput('misc/*');
         return $factory;
     });
 }
开发者ID:lukezbihlyj,项目名称:silex-assets,代码行数:18,代码来源:Module.php


示例20: getChildren

 public function getChildren(AssetFactory $factory, $content, $loadPath = null)
 {
     $loadPaths = $this->loadPaths;
     if (null !== $loadPath) {
         $loadPaths[] = $loadPath;
     }
     if (empty($loadPaths)) {
         return array();
     }
     $children = array();
     foreach (LessUtils::extractImports($content) as $reference) {
         if ('.css' === substr($reference, -4)) {
             // skip normal css imports
             // todo: skip imports with media queries
             continue;
         }
         if ('.less' !== substr($reference, -5)) {
             $reference .= '.less';
         }
         foreach ($loadPaths as $loadPath) {
             if (file_exists($file = $loadPath . '/' . $reference)) {
                 $coll = $factory->createAsset($file, array(), array('root' => $loadPath));
                 foreach ($coll as $leaf) {
                     $leaf->ensureFilter($this);
                     $children[] = $leaf;
                     goto next_reference;
                 }
             }
         }
         next_reference:
     }
     return $children;
 }
开发者ID:k4ml,项目名称:laravel-base,代码行数:33,代码来源:LessPhpFilter.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Auryn\Injector类代码示例发布时间:2022-05-23
下一篇:
PHP Exception\FilterException类代码示例发布时间: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