From 568affa363551af51421a44d088d2a0af6be590b Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Mon, 24 Jun 2024 10:57:56 +0200 Subject: [PATCH] Fully deprecate controller resolver auto mapping (#1804) --- UPGRADE-2.13.md | 13 +++++++++++++ UPGRADE-3.0.md | 8 ++++---- src/DependencyInjection/DoctrineExtension.php | 4 ++++ tests/baseline-ignore | 3 ++- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 UPGRADE-2.13.md diff --git a/UPGRADE-2.13.md b/UPGRADE-2.13.md new file mode 100644 index 00000000..2b0f9579 --- /dev/null +++ b/UPGRADE-2.13.md @@ -0,0 +1,13 @@ +UPGRADE FROM 2.12 to 2.13 +======================== + +Configuration +------------- + +### Controller resolver auto mapping deprecated + +The controller resolver auto mapping functionality has been deprecated with Symfony 7.1, and is replaced with explicit mapped route parameters. Enabling the auto mapper by default using this bundle is now deprecated as well. + +Auto mapping uses any route parameter that matches with a field name of the Entity to resolve as criteria in a find by query. + +If you are relying on this functionality, you can update your code to use explicit mapped route parameters instead. diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index faf694be..365cd13e 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -4,13 +4,13 @@ UPGRADE FROM 2.x to 3.0 Configuration ------------- -### Controller resolver auto mapping default configuration changed +### Controller resolver auto mapping can no longer be configured -The default value of `doctrine.orm.controller_resolver.auto_mapping` has changed from `true` to `false`. +The `doctrine.orm.controller_resolver.auto_mapping` option now only accepts `false` as value, to disallow the usage of the controller resolver auto mapping feature by default. The configuration option will be fully removed in 4.0. -Auto mapping uses any route parameter that matches with a field name of the Entity to resolve as criteria in a find by query. +Auto mapping used any route parameter that matches with a field name of the Entity to resolve as criteria in a find by query. This method has been deprecated in Symfony 7.1 and is replaced with mapped route parameters. -If you were relying on this functionality, you will need to explicitly configure this now. +If you were relying on this functionality, you will need to update your code to use explicit mapped route parameters instead. Types ----- diff --git a/src/DependencyInjection/DoctrineExtension.php b/src/DependencyInjection/DoctrineExtension.php index 62ca3bde..26c8c9af 100644 --- a/src/DependencyInjection/DoctrineExtension.php +++ b/src/DependencyInjection/DoctrineExtension.php @@ -529,6 +529,10 @@ protected function ormLoad(array $config, ContainerBuilder $container) $config['controller_resolver']['auto_mapping'] = true; } + if ($config['controller_resolver']['auto_mapping'] === true) { + trigger_deprecation('doctrine/doctrine-bundle', '2.13', 'Enabling the controller resolver automapping feature has been deprecated. Symfony Mapped Route Parameters should be used as replacement.'); + } + if (! $config['controller_resolver']['auto_mapping']) { $controllerResolverDefaults['mapping'] = []; } diff --git a/tests/baseline-ignore b/tests/baseline-ignore index b17b832e..70943f41 100644 --- a/tests/baseline-ignore +++ b/tests/baseline-ignore @@ -1 +1,2 @@ -%"doctrine.orm.controller_resolver.auto_mapping" will be changed from `true` to `false`.% \ No newline at end of file +%"doctrine.orm.controller_resolver.auto_mapping" will be changed from `true` to `false`.% +%Enabling the controller resolver automapping feature has been deprecated.% \ No newline at end of file