OptimizedPhpArrayDumper::getReferenceCall

protected OptimizedPhpArrayDumper::getReferenceCall($id, Reference $reference = NULL)

Gets a service reference for a reference in a suitable PHP array format.

The main difference is that this function treats references to private services differently and returns a private service reference instead of a normal reference.

Parameters

string $id: The ID of the service to get a reference for.

\Symfony\Component\DependencyInjection\Reference|null $reference: (optional) The reference object to process; needed to get the invalid behavior value.

Return value

string|\stdClass A suitable representation of the service reference.

File

core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php, line 450

Class

OptimizedPhpArrayDumper
OptimizedPhpArrayDumper dumps a service container as a serialized PHP array.

Namespace

Drupal\Component\DependencyInjection\Dumper

Code

protected function getReferenceCall($id, Reference $reference = NULL) {
  $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;

  if ($reference !== NULL) {
    $invalid_behavior = $reference->getInvalidBehavior();
  }

  // Private shared service.
  if (isset($this->aliases[$id])) {
    $id = $this->aliases[$id];
  }
  $definition = $this->container->getDefinition($id);
  if (!$definition->isPublic()) {
    // The ContainerBuilder does not share a private service, but this means a
    // new service is instantiated every time. Use a private shared service to
    // circumvent the problem.
    return $this->getPrivateServiceCall($id, $definition, TRUE);
  }

  return $this->getServiceCall($id, $invalid_behavior);
}
doc_Drupal
2016-10-29 09:32:37
Comments
Leave a Comment

Please login to continue.