public function testExpressionLanguageProviderForwarding()
    {
        $tmpProviders = array();

        $extension = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')->getMock();
        $extension->expects($this->any())
            ->method('getXsdValidationBasePath')
            ->will($this->returnValue(false));
        $extension->expects($this->any())
            ->method('getNamespace')
            ->will($this->returnValue('http://example.org/schema/dic/foo'));
        $extension->expects($this->any())
            ->method('getAlias')
            ->will($this->returnValue('foo'));
        $extension->expects($this->once())
            ->method('load')
            ->will($this->returnCallback(function (array $config, ContainerBuilder $container) use (&$tmpProviders) {
                $tmpProviders = $container->getExpressionLanguageProviders();
            }));

        $provider = $this->getMockBuilder('Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface')->getMock();
        $container = new ContainerBuilder(new ParameterBag());
        $container->registerExtension($extension);
        $container->prependExtensionConfig('foo', array('bar' => true));
        $container->addExpressionLanguageProvider($provider);

        $pass = new MergeExtensionConfigurationPass();
        $pass->process($container);

        $this->assertEquals(array($provider), $tmpProviders);
    }
 public function process(ContainerBuilder $container)
 {
     foreach ($this->extensions as $extension) {
         if (!count($container->getExtensionConfig($extension))) {
             $container->loadFromExtension($extension, array());
         }
     }
     parent::process($container);
 }
 public function testUserParametersAreMostImportantThanDefaultOne()
 {
     $container = new ContainerBuilder();
     $container->getParameterBag()->set('key', 'user_value');
     $container->registerExtension(new ExtensionA());
     $container->loadFromExtension('a');
     $container->registerExtension($b = new ExtensionB());
     $container->loadFromExtension('b');
     $pass = new MergeExtensionConfigurationPass();
     $pass->process($container);
     $this->assertSame('user_value', $container->getParameter('key'));
     $this->assertSame('user_value', $b->parameterKey);
 }
 public function process(ContainerBuilder $container)
 {
     foreach ($container->getParameter('kernel.bundles') as $bundleName => $bundleClass) {
         $bundleRefl = new \ReflectionClass($bundleClass);
         $extClass = $bundleRefl->getNamespaceName() . '\\DependencyInjection\\' . substr($bundleName, 0, -6) . 'Extension';
         if (class_exists($extClass)) {
             $ext = new $extClass();
             $alias = $ext->getAlias();
             // ensure all "main" extensions are loaded
             if (!count($container->getExtensionConfig($alias))) {
                 $container->loadFromExtension($alias, array());
             }
         }
     }
     parent::process($container);
 }
 /**
  * Ensures enabled extensions being loaded by the container.
  *
  * @see EnabledExtensionInterface
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $extensions = array_filter($container->getExtensions(), function ($extension) {
         return $extension instanceof EnabledExtensionInterface;
     });
     $names = array_map(function (ExtensionInterface $extension) {
         return $extension->getAlias();
     }, $extensions);
     array_walk($names, function ($extension) use($container) {
         // Only apply to extension, if there is no configuration supplied.
         if (!count($container->getExtensionConfig($extension))) {
             $container->loadFromExtension($extension, []);
         }
     });
     parent::process($container);
 }