You are here

public function ResolveParameterPlaceHoldersPass::process in Service Container 7

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

Processes the ContainerBuilder to resolve parameter placeholders.

Parameters

ContainerBuilder $container:

Throws

ParameterNotFoundException

Overrides CompilerPassInterface::process

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php, line 31

Class

ResolveParameterPlaceHoldersPass
Resolves all parameter placeholders "%somevalue%" to their real values.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

public function process(ContainerBuilder $container) {
  $parameterBag = $container
    ->getParameterBag();
  foreach ($container
    ->getDefinitions() as $id => $definition) {
    try {
      $definition
        ->setClass($parameterBag
        ->resolveValue($definition
        ->getClass()));
      $definition
        ->setFile($parameterBag
        ->resolveValue($definition
        ->getFile()));
      $definition
        ->setArguments($parameterBag
        ->resolveValue($definition
        ->getArguments()));
      if ($definition
        ->getFactoryClass(false)) {
        $definition
          ->setFactoryClass($parameterBag
          ->resolveValue($definition
          ->getFactoryClass()));
      }
      $factory = $definition
        ->getFactory();
      if (is_array($factory) && isset($factory[0])) {
        $factory[0] = $parameterBag
          ->resolveValue($factory[0]);
        $definition
          ->setFactory($factory);
      }
      $calls = array();
      foreach ($definition
        ->getMethodCalls() as $name => $arguments) {
        $calls[$parameterBag
          ->resolveValue($name)] = $parameterBag
          ->resolveValue($arguments);
      }
      $definition
        ->setMethodCalls($calls);
      $definition
        ->setProperties($parameterBag
        ->resolveValue($definition
        ->getProperties()));
    } catch (ParameterNotFoundException $e) {
      $e
        ->setSourceId($id);
      throw $e;
    }
  }
  $aliases = array();
  foreach ($container
    ->getAliases() as $name => $target) {
    $aliases[$parameterBag
      ->resolveValue($name)] = $parameterBag
      ->resolveValue($target);
  }
  $container
    ->setAliases($aliases);
  $parameterBag
    ->resolve();
}