You are here

private function PhpDumper::addAliases in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php \Symfony\Component\DependencyInjection\Dumper\PhpDumper::addAliases()

Adds the aliases property definition.

Return value

string

2 calls to PhpDumper::addAliases()
PhpDumper::addConstructor in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Adds the constructor.
PhpDumper::addFrozenConstructor in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Adds the constructor for a frozen container.

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php, line 974

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function addAliases() {
  if (!($aliases = $this->container
    ->getAliases())) {
    if ($this->container
      ->isFrozen()) {
      return "\n        \$this->aliases = array();\n";
    }
    else {
      return '';
    }
  }
  $code = "        \$this->aliases = array(\n";
  ksort($aliases);
  foreach ($aliases as $alias => $id) {
    $id = (string) $id;
    while (isset($aliases[$id])) {
      $id = (string) $aliases[$id];
    }
    $code .= '            ' . var_export($alias, true) . ' => ' . var_export($id, true) . ",\n";
  }
  return $code . "        );\n";
}