Skip to content

[FrameworkBundle] Do not load property_access.xml if the component isn't installed #24605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -900,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(
Expand Down