From d297e2760026f2898a400c3dcc9da50841fcd802 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 18 Oct 2017 16:30:35 +0200 Subject: [PATCH] [FrameworkBundle] Do not load property_access.xml if the component isn't installed --- .../DependencyInjection/FrameworkExtension.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 85a1a9ba20..1d2eb1d8b3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -63,9 +63,6 @@ class FrameworkExtension extends Extension // 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 @@ class FrameworkExtension extends Extension } $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 @@ class FrameworkExtension extends Extension } } - 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']) @@ -900,6 +903,11 @@ class FrameworkExtension extends Extension $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(