function LazyServiceInstantiator::instantiateProxy
Overrides InstantiatorInterface::instantiateProxy
File
-
vendor/
symfony/ dependency-injection/ LazyProxy/ Instantiator/ LazyServiceInstantiator.php, line 24
Class
- LazyServiceInstantiator
- @author Nicolas Grekas <p@tchwork.com>
Namespace
Symfony\Component\DependencyInjection\LazyProxy\InstantiatorCode
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator) : object {
$dumper = new LazyServiceDumper();
if (!$dumper->isProxyCandidate($definition, $asGhostObject, $id)) {
throw new InvalidArgumentException(\sprintf('Cannot instantiate lazy proxy for service "%s".', $id));
}
if (!class_exists($proxyClass = $dumper->getProxyClass($definition, $asGhostObject), false)) {
eval($dumper->getProxyCode($definition, $id));
}
return $asGhostObject ? $proxyClass::createLazyGhost($realInstantiator) : $proxyClass::createLazyProxy($realInstantiator);
}