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);