From f3f2a36ba121fb5ae0c8ea621944c5b552555cc8 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 18 Oct 2017 16:30:35 +0200 Subject: [PATCH 1/2] [FrameworkBundle] Do not load property_access.xml if the component isn't installed --- .../DependencyInjection/FrameworkExtension.php | 13 ++++++++----- .../FrameworkBundle/Resources/config/serializer.xml | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 85a1a9ba208f3..4490e169beb60 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -63,9 +63,6 @@ public function load(array $configs, ContainerBuilder $container) // will be used and everything will still work as expected. $loader->load('translation.xml'); - // Property access is used by both the Form and the Validator component - $loader->load('property_access.xml'); - $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); @@ -129,7 +126,7 @@ public function load(array $configs, ContainerBuilder $container) } $this->registerAnnotationsConfiguration($config['annotations'], $container, $loader); - $this->registerPropertyAccessConfiguration($config['property_access'], $container); + $this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader); if (isset($config['serializer'])) { $this->registerSerializerConfiguration($config['serializer'], $container, $loader); @@ -852,8 +849,14 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde } } - private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container) + private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { + if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { + return; + } + + $loader->load('property_access.xml'); + $container ->getDefinition('property_accessor') ->replaceArgument(0, $config['magic_call']) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml index e5b53e94938e2..3ab2fb124c1cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml @@ -23,7 +23,7 @@ null - + From eb0e642d7d4da1348c14cb9202e5c9d1216f9050 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 18 Oct 2017 18:18:56 +0200 Subject: [PATCH 2/2] Remove the ObjectNormalizer when property access component isn't available --- .../DependencyInjection/FrameworkExtension.php | 5 +++++ .../Bundle/FrameworkBundle/Resources/config/serializer.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 4490e169beb60..1d2eb1d8b3c34 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -903,6 +903,11 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder $loader->load('serializer.xml'); $chainLoader = $container->getDefinition('serializer.mapping.chain_loader'); + if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) { + $container->removeAlias('serializer.property_accessor'); + $container->removeDefinition('serializer.normalizer.object'); + } + $serializerLoaders = array(); if (isset($config['enable_annotations']) && $config['enable_annotations']) { $annotationLoader = new Definition( diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml index 3ab2fb124c1cc..e5b53e94938e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml @@ -23,7 +23,7 @@ null - +