You are here

private function InlineServiceDefinitionsPass::inlineArguments in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php \Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass::inlineArguments()

Processes inline arguments.

Parameters

ContainerBuilder $container The ContainerBuilder:

array $arguments An array of arguments:

Return value

array

1 call to InlineServiceDefinitionsPass::inlineArguments()
InlineServiceDefinitionsPass::process in vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php
Processes the ContainerBuilder for inline service definitions.

File

vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php, line 82

Class

InlineServiceDefinitionsPass
Inline service definitions where this is possible.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function inlineArguments(ContainerBuilder $container, array $arguments) {
  foreach ($arguments as $k => $argument) {
    if (is_array($argument)) {
      $arguments[$k] = $this
        ->inlineArguments($container, $argument);
    }
    elseif ($argument instanceof Reference) {
      if (!$container
        ->hasDefinition($id = (string) $argument)) {
        continue;
      }
      if ($this
        ->isInlineableDefinition($container, $id, $definition = $container
        ->getDefinition($id))) {
        $this->compiler
          ->addLogMessage($this->formatter
          ->formatInlineService($this, $id, $this->currentId));
        if (ContainerInterface::SCOPE_PROTOTYPE !== $definition
          ->getScope()) {
          $arguments[$k] = $definition;
        }
        else {
          $arguments[$k] = clone $definition;
        }
      }
    }
    elseif ($argument instanceof Definition) {
      $argument
        ->setArguments($this
        ->inlineArguments($container, $argument
        ->getArguments()));
      $argument
        ->setMethodCalls($this
        ->inlineArguments($container, $argument
        ->getMethodCalls()));
      $argument
        ->setProperties($this
        ->inlineArguments($container, $argument
        ->getProperties()));
    }
  }
  return $arguments;
}