You are here

private function PhpDumper::addConstructor 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::addConstructor()

Adds the constructor.

Return value

string

1 call to PhpDumper::addConstructor()
PhpDumper::dump in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Dumps the service container as a PHP class.

File

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

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function addConstructor() {
  $targetDirs = $this
    ->exportTargetDirs();
  $arguments = $this->container
    ->getParameterBag()
    ->all() ? 'new ParameterBag($this->getDefaultParameters())' : null;
  $code = <<<EOF

    /**
     * Constructor.
     */
    public function __construct()
    {{<span class="php-variable">$targetDirs</span>}
        parent::__construct({<span class="php-variable">$arguments</span>});

EOF;
  if (count($scopes = $this->container
    ->getScopes()) > 0) {
    $code .= "\n";
    $code .= '        $this->scopes = ' . $this
      ->dumpValue($scopes) . ";\n";
    $code .= '        $this->scopeChildren = ' . $this
      ->dumpValue($this->container
      ->getScopeChildren()) . ";\n";
  }
  $code .= $this
    ->addMethodMap();
  $code .= $this
    ->addAliases();
  $code .= <<<EOF
    }

EOF;
  return $code;
}