On this page
protected function 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\DumperCode
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);
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!DependencyInjection!Dumper!OptimizedPhpArrayDumper.php/function/OptimizedPhpArrayDumper::getReferenceCall/8.1.x