/**
* {@inheritdoc}
*/
public function getProxyFactoryCode(Definition $definition, $id)
{
$instantiation = 'return';
if ($definition->isShared() && ContainerInterface::SCOPE_CONTAINER === $definition->getScope(false)) {
$instantiation .= " \$this->services['{$id}'] =";
} elseif ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== ($scope = $definition->getScope(false))) {
$instantiation .= " \$this->services['{$id}'] = \$this->scopedServices['{$scope}']['{$id}'] =";
}
$methodName = 'get' . Container::camelize($id) . 'Service';
$proxyClass = $this->getProxyClassName($definition);
return <<<EOF
if (\$lazyLoad) {
{$instantiation} new {$proxyClass}(
function (&\$wrappedInstance, \\ProxyManager\\Proxy\\LazyLoadingInterface \$proxy) {
\$wrappedInstance = \$this->{$methodName}(false);
\$proxy->setProxyInitializer(null);
return true;
}
);
}
EOF;
}