You are here

private function PhpDumper::hasReference 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::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 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.
PhpDumper::isSimpleInstance in vendor/symfony/dependency-injection/Dumper/PhpDumper.php
Checks if the definition is a simple instance.

File

vendor/symfony/dependency-injection/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;
}