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


PHP Factory\AssetFactory类代码示例

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


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


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