You are here

private function PhpDumper::addServiceConfigurator in Zircon Profile 8

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

Adds configurator definition.

Parameters

string $id:

Definition $definition:

string $variableName:

Return value

string

3 calls to PhpDumper::addServiceConfigurator()
PhpDumper::addService in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Adds a service.
PhpDumper::addServiceInlinedDefinitions in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Generates the inline definition of a service.
PhpDumper::addServiceInlinedDefinitionsSetup in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Generates the inline definition setup.

File

vendor/symfony/dependency-injection/Dumper/PhpDumper.php, line 520

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function addServiceConfigurator($id, $definition, $variableName = 'instance') {
  if (!($callable = $definition
    ->getConfigurator())) {
    return '';
  }
  if (is_array($callable)) {
    if ($callable[0] instanceof Reference || $callable[0] instanceof Definition && $this->definitionVariables
      ->contains($callable[0])) {
      return sprintf("        %s->%s(\$%s);\n", $this
        ->dumpValue($callable[0]), $callable[1], $variableName);
    }
    $class = $this
      ->dumpValue($callable[0]);

    // If the class is a string we can optimize call_user_func away
    if (strpos($class, "'") === 0) {
      return sprintf("        %s::%s(\$%s);\n", $this
        ->dumpLiteralClass($class), $callable[1], $variableName);
    }
    return sprintf("        call_user_func(array(%s, '%s'), \$%s);\n", $this
      ->dumpValue($callable[0]), $callable[1], $variableName);
  }
  return sprintf("        %s(\$%s);\n", $callable, $variableName);
}