本文整理汇总了PHP中Assetic\Factory\AssetFactory::setAssetManager方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetFactory::setAssetManager方法的具体用法?PHP AssetFactory::setAssetManager怎么用?PHP AssetFactory::setAssetManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Factory\AssetFactory
的用法示例。
在下文中一共展示了AssetFactory::setAssetManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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());
}
示例2: 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));
}
示例3: 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;
}
示例4: 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);
}
示例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: 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);
}
示例8: 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);
}
示例9: 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;
});
}
示例10: 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);
}
示例11: 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']));
});
}
示例12: 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);
}
}
示例13: register
public function register(Container $app)
{
$app['assetic.assets'] = $app['assetic.filters'] = $app['assetic.workers'] = array();
$app['assetic.asset_manager'] = function () use($app) {
$am = new AssetManager();
if (isset($app['assetic.assets'])) {
$assets = $app['assetic.assets'];
if (!is_array($assets)) {
$assets = array($assets);
}
foreach ($assets as $name => $asset) {
if (!is_array($asset)) {
// não collection, transformar em collection
$asset = array($asset);
}
$col = new AssetCollection();
foreach ($asset as $a) {
if (is_string($a)) {
// é referencia
$a = new AssetReference($am, $a);
}
if (!$a instanceof AssetInterface) {
throw new \InvalidArgumentException("'assetic.assets' precisa ser um array de AssetInterface");
}
$col->add($a);
}
$am->set($name, $col);
}
}
return $am;
};
$app['assetic.filter_manager'] = function () use($app) {
$fm = new FilterManager();
if (isset($app['assetic.filters'])) {
$filters = $app['assetic.filters'];
if (!is_array($filters)) {
$filters = array($filters);
}
foreach ($filters as $name => $filter) {
$fm->set($name, $filter);
}
}
return $fm;
};
$app['assetic.factory'] = function () use($app) {
$factory = new AssetFactory($app['assetic.dist_path']);
$factory->setAssetManager($app['assetic.asset_manager']);
$factory->setFilterManager($app['assetic.filter_manager']);
$factory->setDebug(isset($app['debug']) ? $app['debug'] : false);
$factory->setDefaultOutput($app['assetic.dist_path']);
if (isset($app['assetic.workers']) && is_array($app['assetic.workers'])) {
foreach ($app['assetic.workers'] as $worker) {
$factory->addWorker($worker);
}
}
return $factory;
};
$app['assetic.lazy_asset_manager'] = function () use($app) {
$am = new LazyAssetManager($app['assetic.factory']);
if (isset($app['twig'])) {
// carrega os assets pelo twig
$am->setLoader('twig', new TwigFormulaLoader($app['twig']));
$loader = $app['twig.loader.filesystem'];
$namespaces = $loader->getNamespaces();
foreach ($namespaces as $ns) {
if (count($loader->getPaths($ns)) > 0) {
$iterator = Finder::create()->files()->in($loader->getPaths($ns));
foreach ($iterator as $file) {
$resource = new TwigResource($loader, '@' . $ns . '/' . $file->getRelativePathname());
$am->addResource($resource, 'twig');
}
}
}
}
return $am;
};
$app['assetic.asset_writer'] = function () use($app) {
return new AssetWriter($app['assetic.dist_path']);
};
if (isset($app['twig'])) {
$app['twig'] = $app->extend('twig', function ($twig, $app) {
$functions = array('cssrewrite' => array('options' => array('combine' => true)));
$twig->addExtension(new AsseticExtension($app['assetic.factory'], $functions));
return $twig;
});
}
}
示例14: createAssetFactory
/**
* @param array $configuration
* @return Factory\AssetFactory
*/
public function createAssetFactory(array $configuration)
{
$factory = new Factory\AssetFactory($configuration['root_path']);
$factory->setAssetManager($this->getAssetManager());
$factory->setFilterManager($this->getFilterManager());
// Cache buster should be add only if cache is enabled and if is available.
if ($this->configuration->getCacheEnabled()) {
$worker = $this->getCacheBusterStrategy();
if ($worker instanceof WorkerInterface) {
$factory->addWorker($worker);
}
}
$factory->setDebug($this->configuration->isDebug());
return $factory;
}
示例15: register
/**
* Registers services on the given container.
*
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param Container $pimple An Container instance
*/
public function register(Container $pimple)
{
/*
* Default configuration.
*/
$pimple['assetic.debug'] = false;
$pimple['assetic.assets'] = array();
$pimple['assetic.variables'] = array();
$pimple['assetic.register_functions'] = true;
$pimple['assetic.java.bin'] = '/usr/bin/java';
$pimple['assetic.node.bin'] = '/usr/bin/node';
$pimple['assetic.node.paths'] = array();
$pimple['assetic.ruby.bin'] = '/usr/bin/ruby';
$pimple['assetic.sass.bin'] = '/usr/bin/sass';
/*
* Finds IDs of all Asset Manager services.
*/
$pimple['assetic.asset_managers'] = $pimple->factory(function (Container $c) {
$ids = preg_grep(self::ASSET_MANAGER_MATCH, $c->keys());
return $ids;
});
/*
* Asset Factory configuration happens here
*
* @param Container $c
* @return mixed
*/
$pimple['assetic'] = function (Container $c) {
// initializing lazy asset manager
if (isset($c['assetic.assets']) && is_array($c['assetic.assets']) && !empty($c['assetic.assets'])) {
$c['assetic.lazy_asset_manager'];
}
return $c['assetic.factory'];
};
/*
* Factory
*
* @param Container $c
* @return AssetFactory
*/
$pimple['assetic.factory'] = function (Container $c) {
$root = isset($c['assetic.read_from']) ? $c['assetic.read_from'] : $c['assetic.write_to'];
$factory = new AssetFactory($root, $c['assetic.debug']);
$factory->setAssetManager($c['assetic.asset_manager']);
$factory->setFilterManager($c['assetic.filter_manager']);
// Optionally enable the global asset functions.
if ($c['assetic.register_functions']) {
assetic_init($factory);
}
return $factory;
};
/*
* Asset writer, writes to the 'assetic.write_to' folder
*
* @param Container $c
* @return AssetWriter
*/
$pimple['assetic.asset_writer'] = function (Container $c) {
return new AssetWriter($c['assetic.write_to']);
};
/*
* Asset manager
*
* @return AssetManager
*/
$pimple['assetic.asset_manager'] = function () {
return new AssetManager();
};
/*
* Filter manager
*
* @return FilterManager
*/
$pimple['assetic.filter_manager'] = function () {
return new FilterManager();
};
/*
* Lazy asset manager for loading assets from $pimple['assetic.assets']
*
* @param Container $c
* @return \Assetic\Factory\LazyAssetManager
*/
$pimple['assetic.lazy.asset_manager'] = function (Container $c) {
$lazy = new LazyAssetManager($c['assetic.factory']);
foreach ($c['assetic.assets'] as $name => $formula) {
$lazy->setFormula($name, $formula);
}
return $lazy;
};
}