Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d297e27

Browse files
ogizanagifabpot
authored andcommitted
[FrameworkBundle] Do not load property_access.xml if the component isn't installed
1 parent bb8f153 commit d297e27

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public function load(array $configs, ContainerBuilder $container)
6363
// will be used and everything will still work as expected.
6464
$loader->load('translation.xml');
6565

66-
// Property access is used by both the Form and the Validator component
67-
$loader->load('property_access.xml');
68-
6966
$configuration = $this->getConfiguration($configs, $container);
7067
$config = $this->processConfiguration($configuration, $configs);
7168

@@ -129,7 +126,7 @@ public function load(array $configs, ContainerBuilder $container)
129126
}
130127

131128
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
132-
$this->registerPropertyAccessConfiguration($config['property_access'], $container);
129+
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
133130

134131
if (isset($config['serializer'])) {
135132
$this->registerSerializerConfiguration($config['serializer'], $container, $loader);
@@ -852,8 +849,14 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
852849
}
853850
}
854851

855-
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container)
852+
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
856853
{
854+
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
855+
return;
856+
}
857+
858+
$loader->load('property_access.xml');
859+
857860
$container
858861
->getDefinition('property_accessor')
859862
->replaceArgument(0, $config['magic_call'])
@@ -900,6 +903,11 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
900903
$loader->load('serializer.xml');
901904
$chainLoader = $container->getDefinition('serializer.mapping.chain_loader');
902905

906+
if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccessor')) {
907+
$container->removeAlias('serializer.property_accessor');
908+
$container->removeDefinition('serializer.normalizer.object');
909+
}
910+
903911
$serializerLoaders = array();
904912
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
905913
$annotationLoader = new Definition(

0 commit comments

Comments
 (0)