diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/ProxyServicesPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/ProxyServicesPass.php index 494e8db..b1510bd 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/ProxyServicesPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/ProxyServicesPass.php @@ -11,6 +11,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; /** * Replaces all services with a lazy flag. @@ -23,18 +24,17 @@ class ProxyServicesPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $service_id => $definition) { if ($definition->isLazy()) { - // Copy the existing definition to a new entry. - $definition->setLazy(FALSE); - // Ensure that the service is accessible. - $definition->setPublic(TRUE); - $new_service_id = 'drupal.proxy_service.' . $service_id; - $container->setDefinition($new_service_id, $definition); - $proxy_class = ProxyBuilder::buildProxyClassName($definition->getClass()); if (class_exists($proxy_class)) { - $proxy_definition = new Definition($proxy_class); - $proxy_definition->setArguments(['service_container', $new_service_id]); - + // Copy the existing definition to a new entry. + $definition->setLazy(FALSE); + // Ensure that the service is accessible. + $definition->setPublic(TRUE); + $new_service_id = 'drupal.proxy_original_service.' . $service_id; + $container->setDefinition($new_service_id, $definition); + + $container->register($service_id, $proxy_class) + ->setArguments([new Reference('service_container'), $new_service_id]); } } }