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


PHP ContainerBuilder::merge方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::merge方法的具体用法?PHP ContainerBuilder::merge怎么用?PHP ContainerBuilder::merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder::merge方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMergingContainsHaveAllServicesAfterCompilation

 /** @dataProvider provideAllServicesDefined */
 public function testMergingContainsHaveAllServicesAfterCompilation($definitionId)
 {
     $container2 = new ContainerBuilder();
     $container2->merge($this->container);
     $container2->compile();
     $this->assertTrue($container2->hasDefinition($definitionId));
 }
开发者ID:squareproton,项目名称:bond,代码行数:8,代码来源:FactoryBuilderTest.php

示例2: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $extensionManager = new ExtensionManager();
     foreach ($configs as $config) {
         if (!isset($config['extensions'])) {
             continue;
         }
         foreach ($config['extensions'] as $config) {
             if (!isset($config['class'])) {
                 continue;
             }
             $extensionManager->activateExtension($config['class']);
         }
     }
     $configuration = new Configuration($extensionManager->getActivatedExtensions());
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../resources'));
     $loader->load('services.xml');
     foreach ($extensionManager->getActivatedExtensions() as $extension) {
         $extensionConfig = $config['extensions'][$extension->getName()];
         $tempContainer = new ContainerBuilder(new ParameterBag(array()));
         $tempContainer->addObjectResource($extension);
         // load extension into temporary container
         $extension->load($extensionConfig, $tempContainer);
         // merge temporary container into normal one
         $container->merge($tempContainer);
     }
     $settings = $this->createSettings($config);
     $configurationDefinition = $container->findDefinition('pdepend.configuration');
     $configurationDefinition->setArguments(array($settings));
 }
开发者ID:Jvbzephir,项目名称:pdepend,代码行数:34,代码来源:PdependExtension.php

示例3: resolve

 private function resolve(Definition $definition)
 {
     if (!$this->container->isFrozen()) {
         throw new \LogicException("cannot use create method on factory without freezing/compiling container");
     }
     $subContainer = new ContainerBuilder();
     $subContainer->merge($this->container);
     $subContainer->setDefinition("__tmp__", $definition);
     $subContainer->compile();
     $obj = $subContainer->get("__tmp__");
     return $obj;
 }
开发者ID:squareproton,项目名称:bond,代码行数:12,代码来源:ProxyFactoryNative.php

示例4: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $parameters = $container->getParameterBag()->all();
     $definitions = $container->getDefinitions();
     $aliases = $container->getAliases();
     foreach ($container->getExtensions() as $name => $extension) {
         $tmpContainer = new ContainerBuilder($container->getParameterBag());
         $tmpContainer->addObjectResource($extension);
         $extension->load($container->getExtensionConfig($name), $tmpContainer);
         $container->merge($tmpContainer);
     }
     $container->addDefinitions($definitions);
     $container->addAliases($aliases);
     $container->getParameterBag()->add($parameters);
 }
开发者ID:noelg,项目名称:symfony-demo,代码行数:18,代码来源:MergeExtensionConfigurationPass.php

示例5: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $parameters = $container->getParameterBag()->all();
     $definitions = $container->getDefinitions();
     $aliases = $container->getAliases();
     foreach ($container->getExtensionConfigs() as $name => $configs) {
         list($namespace, $tag) = explode(':', $name);
         $extension = $container->getExtension($namespace);
         $tmpContainer = new ContainerBuilder($container->getParameterBag());
         $tmpContainer->addObjectResource($extension);
         $extension->load($tag, $configs, $tmpContainer);
         $container->merge($tmpContainer);
     }
     $container->addDefinitions($definitions);
     $container->addAliases($aliases);
     $container->getParameterBag()->add($parameters);
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:20,代码来源:MergeExtensionConfigurationPass.php

示例6: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $parameters = $container->getParameterBag()->all();
     $definitions = $container->getDefinitions();
     $aliases = $container->getAliases();
     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->addObjectResource($extension);
         $extension->load($config, $tmpContainer);
         $container->merge($tmpContainer);
     }
     $container->addDefinitions($definitions);
     $container->addAliases($aliases);
     $container->getParameterBag()->add($parameters);
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:23,代码来源:MergeExtensionConfigurationPass.php

示例7: testMergeLogicException

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::merge
  * @expectedException \LogicException
  */
 public function testMergeLogicException()
 {
     $container = new ContainerBuilder();
     $container->setResourceTracking(false);
     $container->compile();
     $container->merge(new ContainerBuilder());
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:11,代码来源:ContainerBuilderTest.php

示例8: loadExtensionsConfiguration

 /**
  * Loads extensions configuration.
  *
  * @param array            $config
  * @param ContainerBuilder $container
  */
 protected function loadExtensionsConfiguration(array $config, ContainerBuilder $container)
 {
     foreach ($config as $id => $extensionConfig) {
         // load extension from manager
         $extension = $this->extensionManager->getExtension($id);
         // create temporary container
         $tempContainer = new ContainerBuilder(new ParameterBag(array('behat.paths.base' => $container->getParameter('behat.paths.base'), 'behat.extension.classes' => $container->getParameter('behat.extension.classes'))));
         $tempContainer->addObjectResource($extension);
         // load extension into temporary container
         $extension->load($extensionConfig, $tempContainer);
         // merge temporary container into normal one
         $container->merge($tempContainer);
         // add extension compiler passes
         array_map(array($container, 'addCompilerPass'), $extension->getCompilerPasses());
     }
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:22,代码来源:BehatExtension.php

示例9: mergeContainer

 public function mergeContainer(Container $container)
 {
     $this->container->merge($container);
 }
开发者ID:squareproton,项目名称:bond,代码行数:4,代码来源:Configurator.php

示例10: testMergeLogicException

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::merge
  * @expectedException LogicException
  */
 public function testMergeLogicException()
 {
     $container = new ContainerBuilder();
     $container->compile();
     $container->merge(new ContainerBuilder());
 }
开发者ID:notbrain,项目名称:symfony,代码行数:10,代码来源:ContainerBuilderTest.php

示例11: testMerge

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::merge
  */
 public function testMerge()
 {
     $container = new ContainerBuilder(new ParameterBag(array('bar' => 'foo')));
     $config = new ContainerBuilder(new ParameterBag(array('foo' => 'bar')));
     $container->merge($config);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $container->getParameterBag()->all(), '->merge() merges current parameters with the loaded ones');
     $container = new ContainerBuilder(new ParameterBag(array('bar' => 'foo')));
     $config = new ContainerBuilder(new ParameterBag(array('foo' => '%bar%')));
     $container->merge($config);
     ////// FIXME
     $container->freeze();
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo'), $container->getParameterBag()->all(), '->merge() evaluates the values of the parameters towards already defined ones');
     $container = new ContainerBuilder(new ParameterBag(array('bar' => 'foo')));
     $config = new ContainerBuilder(new ParameterBag(array('foo' => '%bar%', 'baz' => '%foo%')));
     $container->merge($config);
     ////// FIXME
     $container->freeze();
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'foo', 'baz' => 'foo'), $container->getParameterBag()->all(), '->merge() evaluates the values of the parameters towards already defined ones');
     $container = new ContainerBuilder();
     $container->register('foo', 'FooClass');
     $container->register('bar', 'BarClass');
     $config = new ContainerBuilder();
     $config->setDefinition('baz', new Definition('BazClass'));
     $config->setAlias('alias_for_foo', 'foo');
     $container->merge($config);
     $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones');
     $this->assertEquals(array('alias_for_foo' => 'foo'), $container->getAliases(), '->merge() registers defined aliases');
     $container = new ContainerBuilder();
     $container->register('foo', 'FooClass');
     $config->setDefinition('foo', new Definition('BazClass'));
     $container->merge($config);
     $this->assertEquals('BazClass', $container->getDefinition('foo')->getClass(), '->merge() overrides already defined services');
 }
开发者ID:netixpro,项目名称:symfony,代码行数:36,代码来源:ContainerBuilderTest.php

示例12: prepend

 /**
  * Allow an extension to prepend the extension configurations.
  *
  * @param ContainerBuilder $container
  */
 public function prepend(ContainerBuilder $container)
 {
     if (!$this instanceof EntitiesOverridableExtensionInterface) {
         return;
     }
     $mappingConfiguration = $this->getConfigurationInstance();
     if ($mappingConfiguration instanceof ConfigurationInterface) {
         $config = $container->getExtensionConfig($this::getExtensionName());
         $config = $container->getParameterBag()->resolveValue($config);
         $tmpContainer = new ContainerBuilder($container->getParameterBag());
         $tmpContainer->setResourceTracking($container->isTrackingResources());
         $tmpContainer->addObjectResource($this);
         $this->loadMappingConfiguration($tmpContainer, $mappingConfiguration, $config);
         $container->merge($tmpContainer);
     }
     /**
      * Perform overrides for Doctrine ORM mapping resolves
      */
     $overrides = $this->getEntitiesOverrides();
     foreach ($overrides as $interface => $override) {
         $overrides[$interface] = $container->getParameter($override);
     }
     $container->prependExtensionConfig('doctrine', ['orm' => ['resolve_target_entities' => $overrides]]);
 }
开发者ID:hd-deman,项目名称:elcodi,代码行数:29,代码来源:AbstractExtension.php

示例13: testMergeLogicException

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::merge
  * @expectedException LogicException
  */
 public function testMergeLogicException()
 {
     if (!class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
         $this->markTestSkipped('The "Config" component is not available');
     }
     $container = new ContainerBuilder();
     $container->compile();
     $container->merge(new ContainerBuilder());
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:13,代码来源:ContainerBuilderTest.php

示例14: loadExtensionsConfiguration

 /**
  * Loads extensions configuration.
  *
  * @param array            $config
  * @param ContainerBuilder $container
  */
 protected function loadExtensionsConfiguration(array $config, ContainerBuilder $container)
 {
     foreach ($config as $id => $extensionConfig) {
         // create temporary container
         $tempContainer = new ContainerBuilder();
         $tempContainer->setParameter('behat.paths.base', $this->basePath);
         // load extension into it
         $extension = $this->extensionManager->getExtension($id);
         $extension->load($extensionConfig, $tempContainer);
         // merge temporary container into normal one
         $container->merge($tempContainer);
         // add extension compiler passes
         array_map(array($container, 'addCompilerPass'), $extension->getCompilerPasses());
     }
 }
开发者ID:robintema,项目名称:deshaza.ro,代码行数:21,代码来源:BehatExtension.php


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