本文整理汇总了PHP中Assetic\Factory\AssetFactory::setFilterManager方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetFactory::setFilterManager方法的具体用法?PHP AssetFactory::setFilterManager怎么用?PHP AssetFactory::setFilterManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Factory\AssetFactory
的用法示例。
在下文中一共展示了AssetFactory::setFilterManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: 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);
}
示例12: 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;
});
}
示例13: 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();
$twig->addExtension(new AsseticExtension($factory));
$this->loader = new TwigFormulaLoader($twig);
}
示例14: register
/**
*
* @param Application $app
*/
function register(Application $app)
{
$app['assetic.asset.root'] = '';
$app['assetic.asset.output_root'] = '';
$app['assetic.debug'] = false;
$app['assetic.filter'] = array();
$app['assetic.filter.default'] = array('cssmin' => '\\Assetic\\Filter\\CssMinFilter', 'cssrewrite' => '\\Assetic\\Filter\\CssRewriteFilter');
$app['assetic.filter_manager'] = $app->share(function ($app) {
$filterManager = new FilterManager();
return $filterManager;
});
$app['assetic.asset_manager'] = $app->share(function ($app) {
$assetManager = new AssetManager();
return $assetManager;
});
$app['assetic.asset_factory'] = $app->share(function ($app) {
$assetFactory = new AssetFactory($app['assetic.asset.root']);
$assetFactory->setDefaultOutput($app['assetic.asset.output_root']);
$assetFactory->setFilterManager($app['assetic.filter_manager']);
$assetFactory->setAssetManager($app['assetic.asset_manager']);
$assetFactory->setDebug($app['assetic.debug']);
return $assetFactory;
});
$app['assetic.lazy_asset_manager'] = $app->share(function ($app) {
$lazyAssetManager = new LazyAssetManager($app['assetic.asset_factory']);
$lazyAssetManager->setLoader('twig', new TwigAsseticIntegrationFormulaLoader($app['twig'], null, $app));
return $lazyAssetManager;
});
$app['assetic.asset_writer'] = $app->share(function ($app) {
$assetWriter = new AssetWriter($app['assetic.asset.output_root']);
return $assetWriter;
});
/*
* Twig
*
*/
// Replace Twig loader
$app['twig.loader.filesystem'] = $app->share(function ($app) {
return new \Wake\Twig_AsseticLoader_Filesystem($app['twig.path']);
});
$app['twig.loader'] = $app->share(function ($app) {
return new \Wake\Twig_AsseticLoader_Chain(array($app['twig.loader.array'], $app['twig.loader.filesystem']));
});
}
示例15: register
public function register()
{
// Register the asset manager singleton
$this->app->bindShared('Concrete\\Package\\AssetPipeline\\Src\\Asset\\UtilityInterface', function ($app) {
return new AssetUtility($app);
});
// Register filter settings repository singleton
$this->app->singleton('Concrete\\Package\\AssetPipeline\\Src\\Asset\\Filter\\SettingsRepositoryInterface', 'Concrete\\Package\\AssetPipeline\\Src\\Asset\\Filter\\SettingsRepository');
// Register Assetic's AssetFactory
$this->app->bindShared('Assetic\\Factory\\AssetFactory', function ($app) {
$am = new AssetManager();
$fm = new FilterManager();
$factory = new AssetFactory(DIR_BASE);
$factory->setAssetManager($am);
$factory->setFilterManager($fm);
return $factory;
});
$singletons = array('helper/assets' => '\\Concrete\\Package\\AssetPipeline\\Src\\Service\\Assets');
foreach ($singletons as $key => $value) {
$this->app->singleton($this->pkgHandle . '/' . $key, $value);
}
}