@@ -42,6 +42,7 @@ class FrameworkExtension extends Extension
4242private $ translationConfigEnabled =false ;
4343private $ sessionConfigEnabled =false ;
4444private $ propertyAccessConfigEnabled =false ;
45+ private $ annotationsConfigEnabled =false ;
4546
4647/**
4748 * @var string|null
@@ -90,11 +91,16 @@ public function load(array $configs, ContainerBuilder $container)
9091$ this ->registerSessionConfiguration ($ config ['session ' ],$ container ,$ loader );
9192 }
9293
93- if ($ this ->isConfigEnabled ($ container ,$ config ['property_access ' ])) {
94+ if ($ this ->isConfigEnabled ($ container ,$ config ['property_access ' ])) {
9495$ this ->propertyAccessConfigEnabled =true ;
9596$ this ->registerPropertyAccessConfiguration ($ config ['property_access ' ],$ container ,$ loader );
9697 }
9798
99+ if ($ this ->isConfigEnabled ($ container ,$ config ['annotations ' ])) {
100+ $ this ->annotationsConfigEnabled =true ;
101+ $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ],$ container ,$ loader );
102+ }
103+
98104if ($ this ->isConfigEnabled ($ container ,$ config ['request ' ])) {
99105$ this ->registerRequestConfiguration ($ config ['request ' ],$ container ,$ loader );
100106 }
@@ -121,23 +127,23 @@ public function load(array $configs, ContainerBuilder $container)
121127$ this ->registerTemplatingConfiguration ($ config ['templating ' ],$ config ['ide ' ],$ container ,$ loader );
122128 }
123129
124- if ($ this ->isConfigEnabled ($ container ,$ config ['validation ' ])) {
130+ if ($ this ->isConfigEnabled ($ container ,$ config ['validation ' ])) {
125131$ this ->registerValidationConfiguration ($ config ['validation ' ],$ container ,$ loader );
126132 }
127133
128- if ($ this ->isConfigEnabled ($ container ,$ config ['esi ' ])) {
134+ if ($ this ->isConfigEnabled ($ container ,$ config ['esi ' ])) {
129135$ loader ->load ('esi.xml ' );
130136 }
131137
132- if ($ this ->isConfigEnabled ($ container ,$ config ['ssi ' ])) {
138+ if ($ this ->isConfigEnabled ($ container ,$ config ['ssi ' ])) {
133139$ loader ->load ('ssi.xml ' );
134140 }
135141
136- if ($ this ->isConfigEnabled ($ container ,$ config ['fragments ' ])) {
142+ if ($ this ->isConfigEnabled ($ container ,$ config ['fragments ' ])) {
137143$ this ->registerFragmentsConfiguration ($ config ['fragments ' ],$ container ,$ loader );
138144 }
139145
140- if ($ this ->isConfigEnabled ($ container ,$ config ['translator ' ])) {
146+ if ($ this ->isConfigEnabled ($ container ,$ config ['translator ' ])) {
141147$ this ->translationConfigEnabled =true ;
142148$ this ->registerTranslatorConfiguration ($ config ['translator ' ],$ container );
143149 }
@@ -148,10 +154,8 @@ public function load(array $configs, ContainerBuilder $container)
148154$ this ->registerRouterConfiguration ($ config ['router ' ],$ container ,$ loader );
149155 }
150156
151- $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ],$ container ,$ loader );
152-
153157if ($ this ->isConfigEnabled ($ container ,$ config ['serializer ' ])) {
154- $ this ->registerSerializerConfiguration ($ config ,$ container ,$ loader );
158+ $ this ->registerSerializerConfiguration ($ config[ ' serializer ' ] ,$ container ,$ loader );
155159 }
156160
157161if ($ this ->isConfigEnabled ($ container ,$ config ['property_info ' ])) {
@@ -228,7 +232,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
228232 */
229233private function registerFormConfiguration ($ config ,ContainerBuilder $ container ,XmlFileLoader $ loader )
230234 {
231- if (!$ this ->propertyAccessConfigEnabled ) {
235+ if (!$ this ->propertyAccessConfigEnabled ) {
232236throw new LogicException ('"framework.property_access" must be enabled when "framework.form" is enabled. ' );
233237 }
234238
@@ -756,7 +760,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
756760return ;
757761 }
758762
759- if (!$ this ->propertyAccessConfigEnabled ) {
763+ if (!$ this ->propertyAccessConfigEnabled ) {
760764throw new LogicException ('"framework.property_access" must be enabled when "framework.validator" is enabled. ' );
761765 }
762766
@@ -779,6 +783,9 @@ private function registerValidationConfiguration(array $config, ContainerBuilder
779783$ definition ->replaceArgument (0 ,$ config ['strict_email ' ]);
780784
781785if (array_key_exists ('enable_annotations ' ,$ config ) &&$ config ['enable_annotations ' ]) {
786+ if (!$ this ->annotationsConfigEnabled ) {
787+ throw new \LogicException ('"framework.annotations" must be enabled when "framework.serializer.enable_annotations" is set to true. ' );
788+ }
782789$ validatorBuilder ->addMethodCall ('enableAnnotationMapping ' ,array (new Reference ('annotation_reader ' )));
783790 }
784791
@@ -905,12 +912,10 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
905912 */
906913private function registerSerializerConfiguration (array $ config ,ContainerBuilder $ container ,XmlFileLoader $ loader )
907914 {
908- if (!$ this ->propertyAccessConfigEnabled ) {
915+ if (!$ this ->propertyAccessConfigEnabled ) {
909916throw new LogicException ('"framework.property_access" must be enabled when "framework.serializer" is enabled. ' );
910917 }
911918
912- $ config =$ config ['serializer ' ];
913-
914919if (class_exists ('Symfony\Component\Serializer\Normalizer\DataUriNormalizer ' )) {
915920// Run after serializer.normalizer.object
916921$ definition =$ container ->register ('serializer.normalizer.data_uri ' , DataUriNormalizer::class);
@@ -937,6 +942,9 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
937942
938943$ serializerLoaders =array ();
939944if (isset ($ config ['enable_annotations ' ]) &&$ config ['enable_annotations ' ]) {
945+ if (!$ this ->annotationsConfigEnabled ) {
946+ throw new \LogicException ('"framework.annotations" must be enabled when "framework.serializer.enable_annotations" is set to true. ' );
947+ }
940948$ annotationLoader =new Definition (
941949'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader ' ,
942950array (new Reference ('annotation_reader ' ))