@@ -34,6 +34,10 @@ public function process(ContainerBuilder $container)
34
34
$ types = array ();
35
35
36
36
foreach ($ container ->findTaggedServiceIds ('form.type ' ) as $ serviceId => $ tag ) {
37
+ $ serviceDefinition = $ container ->getDefinition ($ serviceId );
38
+ if (!$ serviceDefinition ->isPublic ()) {
39
+ throw new \InvalidArgumentException (sprintf ('The service "%s" must be public as form types are lazy-loaded. ' , $ serviceId ));
40
+ }
37
41
// The following if-else block is deprecated and will be removed
38
42
// in Symfony 3.0
39
43
// Deprecation errors are triggered in the form registry
@@ -44,7 +48,6 @@ public function process(ContainerBuilder $container)
44
48
}
45
49
46
50
// Support type access by FQCN
47
- $ serviceDefinition = $ container ->getDefinition ($ serviceId );
48
51
$ types [$ serviceDefinition ->getClass ()] = $ serviceId ;
49
52
}
50
53
@@ -53,6 +56,11 @@ public function process(ContainerBuilder $container)
53
56
$ typeExtensions = array ();
54
57
55
58
foreach ($ container ->findTaggedServiceIds ('form.type_extension ' ) as $ serviceId => $ tag ) {
59
+ $ serviceDefinition = $ container ->getDefinition ($ serviceId );
60
+ if (!$ serviceDefinition ->isPublic ()) {
61
+ throw new \InvalidArgumentException (sprintf ('The service "%s" must be public as form type extensions are lazy-loaded. ' , $ serviceId ));
62
+ }
63
+
56
64
if (isset ($ tag [0 ]['extended_type ' ])) {
57
65
$ extendedType = $ tag [0 ]['extended_type ' ];
58
66
} elseif (isset ($ tag [0 ]['alias ' ])) {
@@ -70,6 +78,12 @@ public function process(ContainerBuilder $container)
70
78
71
79
// Find all services annotated with "form.type_guesser"
72
80
$ guessers = array_keys ($ container ->findTaggedServiceIds ('form.type_guesser ' ));
81
+ foreach ($ guessers as $ serviceId ) {
82
+ $ serviceDefinition = $ container ->getDefinition ($ serviceId );
83
+ if (!$ serviceDefinition ->isPublic ()) {
84
+ throw new \InvalidArgumentException (sprintf ('The service "%s" must be public as form type guessers are lazy-loaded. ' , $ serviceId ));
85
+ }
86
+ }
73
87
74
88
$ definition ->replaceArgument (3 , $ guessers );
75
89
}
0 commit comments