You are here

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

Checks if a service id has a reference.

Parameters

string $id:

array $arguments:

bool $deep:

array $visited:

Return value

bool

3 calls to PhpDumper::hasReference()
PhpDumper::addServiceInlinedDefinitions in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Generates the inline definition of a service.
PhpDumper::addServiceInlinedDefinitionsSetup in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Generates the inline definition setup.
PhpDumper::isSimpleInstance in modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Checks if the definition is a simple instance.

File

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

Class

PhpDumper
PhpDumper dumps a service container as a PHP class.

Namespace

Symfony\Component\DependencyInjection\Dumper

Code

private function hasReference($id, array $arguments, $deep = false, array &$visited = array()) {
  foreach ($arguments as $argument) {
    if (is_array($argument)) {
      if ($this
        ->hasReference($id, $argument, $deep, $visited)) {
        return true;
      }
    }
    elseif ($argument instanceof Reference) {
      $argumentId = (string) $argument;
      if ($id === $argumentId) {
        return true;
      }
      if ($deep && !isset($visited[$argumentId])) {
        $visited[$argumentId] = true;
        $service = $this->container
          ->getDefinition($argumentId);
        $arguments = array_merge($service
          ->getMethodCalls(), $service
          ->getArguments(), $service
          ->getProperties());
        if ($this
          ->hasReference($id, $arguments, $deep, $visited)) {
          return true;
        }
      }
    }
  }
  return false;
}