From 82fa9422aae028ac3f7aab7d27b3644096144e0c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 30 Sep 2016 11:57:07 -0700 Subject: [PATCH] added checks for public services on compiler passes that use service id and not references --- .../Compiler/RuntimeLoaderPass.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php index 4cbc00c788d4a..6a4c1f269053c 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php @@ -28,7 +28,17 @@ public function process(ContainerBuilder $container) $definition = $container->getDefinition('twig.runtime_loader'); $mapping = array(); foreach ($container->findTaggedServiceIds('twig.runtime') as $id => $attributes) { - $mapping[$container->getDefinition($id)->getClass()] = $id; + $def = $container->getDefinition($id); + + if (!$def->isPublic()) { + throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id)); + } + + if ($def->isAbstract()) { + throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id)); + } + + $mapping[$def->getClass()] = $id; } $definition->replaceArgument(1, $mapping);