@@ -159,11 +159,6 @@ public function load(array $configs, ContainerBuilder $container)
159159 }
160160 }
161161
162- // Property access is used by both the Form and the Validator component
163- $ loader ->load ('property_access.xml ' );
164-
165- $ container ->getDefinition ('property_accessor ' )->setPrivate (true );
166-
167162 // Load Cache configuration first as it is used by other components
168163 $ loader ->load ('cache.xml ' );
169164
@@ -287,7 +282,7 @@ public function load(array $configs, ContainerBuilder $container)
287282 $ this ->registerDebugConfiguration ($ config ['php_errors ' ], $ container , $ loader );
288283 $ this ->registerRouterConfiguration ($ config ['router ' ], $ container , $ loader );
289284 $ this ->registerAnnotationsConfiguration ($ config ['annotations ' ], $ container , $ loader );
290- $ this ->registerPropertyAccessConfiguration ($ config ['property_access ' ], $ container );
285+ $ this ->registerPropertyAccessConfiguration ($ config ['property_access ' ], $ container, $ loader );
291286
292287 if ($ this ->isConfigEnabled ($ container , $ config ['serializer ' ])) {
293288 $ this ->registerSerializerConfiguration ($ config ['serializer ' ], $ container , $ loader );
@@ -1377,8 +1372,16 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
13771372 }
13781373 }
13791374
1380- private function registerPropertyAccessConfiguration (array $ config , ContainerBuilder $ container )
1375+ private function registerPropertyAccessConfiguration (array $ config , ContainerBuilder $ container, XmlFileLoader $ loader )
13811376 {
1377+ if (!class_exists ('Symfony\Component\PropertyAccess\PropertyAccessor ' )) {
1378+ return ;
1379+ }
1380+
1381+ $ loader ->load ('property_access.xml ' );
1382+
1383+ $ container ->getDefinition ('property_accessor ' )->setPrivate (true );
1384+
13821385 $ container
13831386 ->getDefinition ('property_accessor ' )
13841387 ->replaceArgument (0 , $ config ['magic_call ' ])
@@ -1416,6 +1419,11 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
14161419
14171420 $ chainLoader = $ container ->getDefinition ('serializer.mapping.chain_loader ' );
14181421
1422+ if (!class_exists ('Symfony\Component\PropertyAccess\PropertyAccessor ' )) {
1423+ $ container ->removeAlias ('serializer.property_accessor ' );
1424+ $ container ->removeDefinition ('serializer.normalizer.object ' );
1425+ }
1426+
14191427 $ serializerLoaders = array ();
14201428 if (isset ($ config ['enable_annotations ' ]) && $ config ['enable_annotations ' ]) {
14211429 if (!$ this ->annotationsConfigEnabled ) {
0 commit comments