You are here

public function MergeExtensionConfigurationPass::process in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php \Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass::process()

You can modify the container here before it is dumped to PHP code.

@api

Parameters

ContainerBuilder $container:

Overrides CompilerPassInterface::process

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php, line 27

Class

MergeExtensionConfigurationPass
Merges extension configs into the container builder.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

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);
}