當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。