8000 added checks for public services on compiler passes that use service … · symfony/symfony@82fa942 · GitHub
[go: up one dir, main page]

Skip to content

Commit 82fa942

Browse files
committed
added checks for public services on compiler passes that use service id and not references
1 parent a1d0136 commit 82fa942

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ public function process(ContainerBuilder $container)
2828
$definition = $container->getDefinition('twig.runtime_loader');
2929
$mapping = array();
3030
foreach ($container->findTaggedServiceIds('twig.runtime') as $id => $attributes) {
31-
$mapping[$container->getDefinition($id)->getClass()] = $id;
31+
$def = $container->getDefinition($id);
32+
33+
if (!$def->isPublic()) {
34+
throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id));
35+
}
36+
37+
if ($def->isAbstract()) {
38+
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id));
39+
}
40+
41+
$mapping[$def->getClass()] = $id;
3242
}
3343

3444
$definition->replaceArgument(1, $mapping);

0 commit comments

Comments
 (0)
0