本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::getExtensions方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::getExtensions方法的具体用法?PHP ContainerBuilder::getExtensions怎么用?PHP ContainerBuilder::getExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::getExtensions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
// process the configuration of SuluCoreExtension
$configs = $container->getExtensionConfig($this->getAlias());
$parameterBag = $container->getParameterBag();
$configs = $parameterBag->resolveValue($configs);
$config = $this->processConfiguration(new Configuration(), $configs);
if (isset($config['phpcr'])) {
$phpcrConfig = $config['phpcr'];
// TODO: Workaround for issue: https://github.com/doctrine/DoctrinePHPCRBundle/issues/178
if (!isset($phpcrConfig['backend']['check_login_on_server'])) {
$phpcrConfig['backend']['check_login_on_server'] = false;
}
foreach ($container->getExtensions() as $name => $extension) {
$prependConfig = [];
switch ($name) {
case 'doctrine_phpcr':
$prependConfig = ['session' => $phpcrConfig, 'odm' => []];
break;
case 'cmf_core':
break;
}
if ($prependConfig) {
$container->prependExtensionConfig($name, $prependConfig);
}
}
}
if ($container->hasExtension('massive_build')) {
$container->prependExtensionConfig('massive_build', ['command_class' => 'Sulu\\Bundle\\CoreBundle\\CommandOptional\\SuluBuildCommand']);
}
}
示例2: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$parameters = $container->getParameterBag()->all();
$definitions = $container->getDefinitions();
$aliases = $container->getAliases();
$exprLangProviders = $container->getExpressionLanguageProviders();
foreach ($container->getExtensions() as $extension) {
if ($extension instanceof PrependExtensionInterface) {
$extension->prepend($container);
}
}
foreach ($container->getExtensions() as $name => $extension) {
if (!($config = $container->getExtensionConfig($name))) {
// this extension was not called
continue;
}
$config = $container->getParameterBag()->resolveValue($config);
$tmpContainer = new ContainerBuilder($container->getParameterBag());
$tmpContainer->setResourceTracking($container->isTrackingResources());
$tmpContainer->addObjectResource($extension);
foreach ($exprLangProviders as $provider) {
$tmpContainer->addExpressionLanguageProvider($provider);
}
$extension->load($config, $tmpContainer);
$container->merge($tmpContainer);
$container->getParameterBag()->add($parameters);
}
$container->addDefinitions($definitions);
$container->addAliases($aliases);
}
示例3: prepend
/**
* @param ContainerBuilder $container
*
* @return void
*/
public function prepend(ContainerBuilder $container)
{
// Build fos_elastica config for each widget
$elasticaConfig = [];
$kernel = new \AppKernel('prod', false);
$yamlParser = new Yaml();
foreach ($kernel->registerBundles() as $bundle) {
/* @var Bundle $bundle */
$path = $bundle->getPath();
//If bundle is a widget
if (0 === strpos($bundle->getNamespace(), 'Victoire\\Widget\\')) {
//find for a fos_elastica.yml config file
$widgetConfig = $yamlParser->parse($path . '/Resources/config/config.yml');
if (is_array($widgetConfig)) {
foreach ($widgetConfig['victoire_core']['widgets'] as $_widgetConfig) {
if (array_key_exists('fos_elastica', $widgetConfig)) {
$_config = ['indexes' => ['widgets' => ['types' => [$_widgetConfig['name'] => ['serializer' => ['groups' => ['search']], 'mappings' => [], 'persistence' => ['driver' => 'orm', 'model' => $_widgetConfig['class'], 'provider' => [], 'listener' => [], 'finder' => []]]]]]];
$_config = array_merge_recursive($widgetConfig['fos_elastica'], $_config);
$elasticaConfig = array_merge_recursive($elasticaConfig, $_config);
}
}
}
}
}
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'fos_elastica':
$container->prependExtensionConfig($name, $elasticaConfig);
break;
}
}
}
示例4: prepend
/**
* Prepend our mediabundle config before all other bundles, so we can preset
* their config with our parameters
*
* @param ContainerBuilder $container
*
* @return void
*/
public function prepend(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$container->setAlias('opifer.media.media_manager', $config['media_manager']);
$parameters = $this->getParameters($config);
foreach ($parameters as $key => $value) {
$container->setParameter($key, $value);
}
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'doctrine':
$container->prependExtensionConfig($name, ['orm' => ['resolve_target_entities' => ['Opifer\\MediaBundle\\Model\\MediaInterface' => $config['media_class']]]]);
break;
case 'twig':
$container->prependExtensionConfig($name, ['form' => ['resources' => ['OpiferMediaBundle:Form:fields.html.twig']]]);
break;
case 'liip_imagine':
$container->prependExtensionConfig($name, ['resolvers' => ['local_storage' => ['web_path' => null], 'aws_storage' => ['aws_s3' => ['client_config' => ['key' => $config['storages']['aws_s3']['key'], 'secret' => $config['storages']['aws_s3']['secret'], 'region' => $config['storages']['aws_s3']['region']], 'bucket' => $config['storages']['aws_s3']['bucket']]]], 'cache' => $config['default_storage'], 'data_loader' => 'stream.file_storage', 'loaders' => ['stream.file_storage' => ['stream' => ['wrapper' => 'gaufrette://file_storage/']]], 'driver' => 'imagick', 'filter_sets' => ['medialibrary' => ['quality' => 100, 'filters' => ['relative_resize' => ['heighten' => 160]]]]]);
break;
case 'knp_gaufrette':
$container->prependExtensionConfig($name, ['adapters' => ['tmp_storage' => ['local' => ['directory' => $config['storages']['temp']['directory']]], 'local_storage' => ['local' => ['directory' => $config['storages']['local']['directory']]], 'aws_storage' => ['aws_s3' => ['service_id' => 'opifer.media.aws_s3.client', 'bucket_name' => $config['storages']['aws_s3']['bucket'], 'options' => ['directory' => 'originals', 'acl' => 'public-read']]]], 'filesystems' => ['tmp_storage' => ['adapter' => 'tmp_storage', 'alias' => 'tmp_storage_filesystem'], 'file_storage' => ['adapter' => $config['default_storage'], 'alias' => 'file_storage_filesystem']], 'stream_wrapper' => null]);
break;
}
}
}
示例5: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
$configLoader = new CumulativeConfigLoader('oro_app_config', new YamlCumulativeFileLoader('Resources/config/oro/app.yml'));
// original security config
$securityConfig = null;
$securityModified = false;
if ($container->hasExtension('security')) {
$securityConfig = $container->getExtensionConfig('security');
}
$resources = $configLoader->load();
$extensions = $container->getExtensions();
foreach ($resources as $resource) {
foreach ($resource->data as $name => $config) {
if (!empty($extensions[$name])) {
if ($name === 'security') {
$this->mergeConfigIntoOne($container, $name, $config);
$securityModified = true;
} else {
$container->prependExtensionConfig($name, $config);
}
}
}
}
// original security config has highest priority
if ($securityConfig && $securityModified) {
$this->mergeConfigIntoOne($container, 'security', reset($securityConfig));
}
$this->preparePostgreSql($container);
}
示例6: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $container->getExtensionConfig($this->getAlias()));
foreach ($container->getExtensions() as $name => $extension) {
if (in_array($name, $this->bundles)) {
$container->prependExtensionConfig($name, ['driver' => $config['driver']]);
}
}
$routeClasses = $controllerByClasses = $repositoryByClasses = $syliusByClasses = [];
foreach ($config['routing'] as $className => $routeConfig) {
$routeClasses[$className] = ['field' => $routeConfig['field'], 'prefix' => $routeConfig['prefix']];
$controllerByClasses[$className] = $routeConfig['defaults']['controller'];
$repositoryByClasses[$className] = $routeConfig['defaults']['repository'];
$syliusByClasses[$className] = $routeConfig['defaults']['sylius'];
}
$container->prependExtensionConfig('sylius_theme', ['context' => 'sylius.theme.context.channel_based']);
$container->setParameter('sylius.route_classes', $routeClasses);
$container->setParameter('sylius.controller_by_classes', $controllerByClasses);
$container->setParameter('sylius.repository_by_classes', $repositoryByClasses);
$container->setParameter('sylius.sylius_by_classes', $syliusByClasses);
$container->setParameter('sylius.route_collection_limit', $config['route_collection_limit']);
$container->setParameter('sylius.route_uri_filter_regexp', $config['route_uri_filter_regexp']);
$container->setParameter('sylius.sitemap', $config['sitemap']);
$container->setParameter('sylius.sitemap_template', $config['sitemap']['template']);
}
示例7: loadExtensions
/**
* Load registered bundles' extensions
*/
protected function loadExtensions()
{
$extensions = $this->container->getExtensions();
foreach ($extensions as $extension) {
$configs = $this->container->getExtensionConfig($extension->getAlias());
$extension->load($configs, $this->container);
}
}
示例8: configureAsseticBundle
protected function configureAsseticBundle(ContainerBuilder $container, array $config)
{
$extensions = $container->getExtensions();
if (true === isset($extensions['assetic'])) {
$asseticConfig = new AsseticConfiguration();
$container->prependExtensionConfig('assetic', array('assets' => $asseticConfig->build($config)));
}
}
示例9: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->getExtensions() as $extension) {
if (!$extension instanceof CompilerPassInterface) {
continue;
}
$extension->process($container);
}
}
示例10: process
public function process(ContainerBuilder $container)
{
foreach ($container->getExtensions() as $extension) {
$parameterName = $extension->getAlias() . '.routing_discriminator.map';
if ($container->hasParameter($parameterName)) {
$this->processParameters($container->getParameter($parameterName), $container);
}
}
}
示例11: prepend
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
{
$config = $this->processConfiguration($this->getBundleConfiguration(), $container->getExtensionConfig($this->getAlias()));
foreach ($container->getExtensions() as $name => $extension) {
if (in_array($name, $this->bundles)) {
$container->prependExtensionConfig($name, array('driver' => $config['driver']));
}
}
}
示例12: prepend
/**
* Allow an extension to prepend the extension configurations.
*
* @param ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container)
{
foreach ($container->getExtensions() as $name => $extension) {
switch ($name) {
case 'twig':
$container->prependExtensionConfig($name, array('form' => array('resources' => array('ExtensionsBundle:Form:datetime_local.html.twig', 'ExtensionsBundle:Form:entity_autocomplete.html.twig'))));
break;
}
}
}
示例13: configureTwigBundle
/**
* @param ContainerBuilder $container The service container
*
* @return void
*/
protected function configureTwigBundle(ContainerBuilder $container)
{
foreach (array_keys($container->getExtensions()) as $name) {
switch ($name) {
case 'twig':
$container->prependExtensionConfig($name, array('form' => array('resources' => array($this->formTemplate))));
break;
}
}
}
示例14: configureSecurityBundle
/**
* @param ContainerBuilder $container The service container
*/
protected function configureSecurityBundle(ContainerBuilder $container)
{
foreach (array_keys($container->getExtensions()) as $name) {
switch ($name) {
case 'security':
$container->prependExtensionConfig($name, array('encoders' => array('FOS\\UserBundle\\Model\\UserInterface' => 'sha512'), 'role_hierarchy' => array('ROLE_ADMIN' => 'ROLE_USER', 'ROLE_SUPER_ADMIN' => 'ROLE_ADMIN')));
break;
}
}
}
示例15: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$classes = array();
foreach ($container->getExtensions() as $extension) {
if ($extension instanceof Extension) {
$classes = array_merge($classes, $extension->getClassesToCompile());
}
}
$this->kernel->setClassCache(array_unique($container->getParameterBag()->resolveValue($classes)));
}