File tree 4 files changed +24
-3
lines changed
DependencyInjection/Compiler
DependencyInjection/Compiler
Tests/DependencyInjection
4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,17 @@ public function process(ContainerBuilder $container)
28
28
$ validators [$ attributes [0 ]['alias ' ]] = $ id ;
29
29
}
30
30
31
- $ validators [$ container ->getDefinition ($ id )->getClass ()] = $ id ;
31
+ $ definition = $ container ->getDefinition ($ id );
32
+
33
+ if (!$ definition ->isPublic ()) {
34
+ throw new InvalidArgumentException (sprintf ('The service "%s" must be public as it can be lazy-loaded. ' , $ id ));
35
+ }
36
+
37
+ if ($ definition ->isAbstract ()) {
38
+ throw new InvalidArgumentException (sprintf ('The service "%s" must not be abstract as it can be lazy-loaded. ' , $ id ));
39
+ }
40
+
41
+ $ validators [$ definition ->getClass ()] = $ id ;
32
42
}
33
43
34
44
$ container ->getDefinition ('validator.validator_factory ' )->replaceArgument (1 , $ validators );
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ public function build(ContainerBuilder $container)
76
76
// but as late as possible to get resolved parameters
77
77
$ container ->addCompilerPass (new RegisterListenersPass (), PassConfig::TYPE_BEFORE_REMOVING );
78
78
$ container ->addCompilerPass (new TemplatingPass ());
79
- $ container ->addCompilerPass (new AddConstraintValidatorsPass ());
79
+ $ container ->addCompilerPass (new AddConstraintValidatorsPass (), PassConfig:: TYPE_BEFORE_REMOVING );
80
80
$ container ->addCompilerPass (new AddValidatorInitializersPass ());
81
81
$ container ->addCompilerPass (new AddConsoleCommandPass ());
82
82
$ container ->addCompilerPass (new FormPass ());
Original file line number Diff line number Diff line change @@ -28,7 +28,17 @@ public function process(ContainerBuilder $container)
28
28
$ definition = $ container ->getDefinition ('twig.runtime_loader ' );
29
29
$ mapping = array ();
30
30
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 ;
32
42
}
33
43
34
44
$ definition ->replaceArgument (1 , $ mapping );
Original file line number Diff line number Diff line change @@ -231,6 +231,7 @@ public function testRuntimeLoader()
231
231
232
232
$ loader = $ container ->getDefinition ('twig.runtime_loader ' );
233
233
$ args = $ loader ->getArgument (1 );
234
+ print_r ($ loader ->getArguments ());
234
235
$ this ->assertArrayHasKey ('Symfony\Bridge\Twig\Form\TwigRenderer ' , $ args );
235
236
$ this ->assertArrayHasKey ('FooClass ' , $ args );
236
237
$ this ->assertContains ('twig.form.renderer ' , $ args );
You can’t perform that action at this time.
0 commit comments