@@ -38,6 +38,7 @@ class FrameworkExtension extends Extension
38
38
private $ translationConfigEnabled = false ;
39
39
private $ sessionConfigEnabled = false ;
40
40
private $ propertyAccessConfigEnabled = false ;
41
+ private $ annotationsConfigEnabled = false ;
41
42
42
43
/**
43
44
* @var string|null
@@ -86,11 +87,16 @@ public function load(array $configs, ContainerBuilder $container)
86
87
$ this ->registerSessionConfiguration ($ config ['session ' ], $ container , $ loader );
87
88
}
88
89
89
- if ($ this ->isConfigEnabled ($ container , $ config ['property_access ' ])) {
90
+ if ($ this ->isConfigEnabled ($ container , $ config ['property_access ' ])) {
90
91
$ this ->propertyAccessConfigEnabled = true ;
91
92
$ this ->registerPropertyAccessConfiguration ($ config ['property_access ' ], $ container , $ loader );
92
93
}
93
94
95
+ if ($ this ->isConfigEnabled ($ container , $ config ['annotations ' ])) {
96
+ $ this ->annotationsConfigEnabled = true ;
97
+ $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ], $ container , $ loader );
98
+ }
99
+
94
100
if ($ this ->isConfigEnabled ($ container , $ config ['request ' ])) {
95
101
$ this ->registerRequestConfiguration ($ config ['request ' ], $ container , $ loader );
96
102
}
@@ -117,23 +123,23 @@ public function load(array $configs, ContainerBuilder $container)
117
123
$ this ->registerTemplatingConfiguration ($ config ['templating ' ], $ config ['ide ' ], $ container , $ loader );
118
124
}
119
125
120
- if ($ this ->isConfigEnabled ($ container , $ config ['validation ' ])) {
126
+ if ($ this ->isConfigEnabled ($ container , $ config ['validation ' ])) {
121
127
$ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ loader );
122
128
}
123
129
124
- if ($ this ->isConfigEnabled ($ container , $ config ['esi ' ])) {
130
+ if ($ this ->isConfigEnabled ($ container , $ config ['esi ' ])) {
125
131
$ loader ->load ('esi.xml ' );
126
132
}
127
133
128
- if ($ this ->isConfigEnabled ($ container , $ config ['ssi ' ])) {
134
+ if ($ this ->isConfigEnabled ($ container , $ config ['ssi ' ])) {
129
135
$ loader ->load ('ssi.xml ' );
130
136
}
131
137
132
- if ($ this ->isConfigEnabled ($ container , $ config ['fragments ' ])) {
138
+ if ($ this ->isConfigEnabled ($ container , $ config ['fragments ' ])) {
133
139
$ this ->registerFragmentsConfiguration ($ config ['fragments ' ], $ container , $ loader );
134
140
}
135
141
136
- if ($ this ->isConfigEnabled ($ container , $ config ['translator ' ])) {
142
+ if ($ this ->isConfigEnabled ($ container , $ config ['translator ' ])) {
137
143
$ this ->translationConfigEnabled = true ;
138
144
$ this ->registerTranslatorConfiguration ($ config ['translator ' ], $ container );
139
145
}
@@ -144,10 +150,8 @@ public function load(array $configs, ContainerBuilder $container)
144
150
$ this ->registerRouterConfiguration ($ config ['router ' ], $ container , $ loader );
145
151
}
146
152
147
- $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ], $ container , $ loader );
148
-
149
153
if ($ this ->isConfigEnabled ($ container , $ config ['serializer ' ])) {
150
- $ this ->registerSerializerConfiguration ($ config , $ container , $ loader );
154
+ $ this ->registerSerializerConfiguration ($ config[ ' serializer ' ] , $ container , $ loader );
151
155
}
152
156
153
157
if ($ this ->isConfigEnabled ($ container , $ config ['property_info ' ])) {
@@ -224,7 +228,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
224
228
*/
225
229
private function registerFormConfiguration ($ config , ContainerBuilder $ container , XmlFileLoader $ loader )
226
230
{
227
- if (!$ this ->propertyAccessConfigEnabled ) {
231
+ if (!$ this ->propertyAccessConfigEnabled ) {
228
232
throw new LogicException ('"framework.property_access" must be enabled when "framework.form" is enabled. ' );
229
233
}
230
234
@@ -748,7 +752,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
748
752
return ;
749
753
}
750
754
751
- if (!$ this ->propertyAccessConfigEnabled ) {
755
+ if (!$ this ->propertyAccessConfigEnabled ) {
752
756
throw new LogicException ('"framework.property_access" must be enabled when "framework.validator" is enabled. ' );
753
757
}
754
758
@@ -771,6 +775,9 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
771
775
$ definition ->replaceArgument (0 , $ config ['strict_email ' ]);
772
776
773
777
if (array_key_exists ('enable_annotations ' , $ config ) && $ config ['enable_annotations ' ]) {
778
+ if (!$ this ->annotationsConfigEnabled ) {
779
+ throw new \LogicException ('"framework.annotations" must be enabled when "framework.serializer.enable_annotations" is set to true. ' );
780
+ }
774
781
$ validatorBuilder ->addMethodCall ('enableAnnotationMapping ' , array (new Reference ('annotation_reader ' )));
775
782
}
776
783
@@ -896,17 +903,18 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
896
903
*/
897
904
private function registerSerializerConfiguration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader )
898
905
{
899
- if (!$ this ->propertyAccessConfigEnabled ) {
906
+ if (!$ this ->propertyAccessConfigEnabled ) {
900
907
throw new LogicException ('"framework.property_access" must be enabled when "framework.serializer" is enabled. ' );
901
908
}
902
909
903
- $ config = $ config ['serializer ' ];
904
-
905
910
$ loader ->load ('serializer.xml ' );
906
911
$ chainLoader = $ container ->getDefinition ('serializer.mapping.chain_loader ' );
907
912
908
913
$ serializerLoaders = array ();
909
914
if (isset ($ config ['enable_annotations ' ]) && $ config ['enable_annotations ' ]) {
915
+ if (!$ this ->annotationsConfigEnabled ) {
916
+ throw new \LogicException ('"framework.annotations" must be enabled when "framework.serializer.enable_annotations" is set to true. ' );
917
+ }
910
918
$ annotationLoader = new Definition (
911
919
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader ' ,
912
920
array (new Reference ('annotation_reader ' ))
0 commit comments