Skip to content

Commit

Permalink
Deprecate not setting doctrine.orm.controller_resolver.auto_mapping (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandevijver authored Mar 14, 2024
1 parent 26a87a7 commit 1a3b650
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ private function addOrmSection(ArrayNodeDefinition $node): void
->canBeDisabled()
->children()
->booleanNode('auto_mapping')
->defaultTrue()
->defaultNull()
->info('Set to false to disable using route placeholders as lookup criteria when the primary key doesn\'t match the argument name')
->end()
->booleanNode('evict_cache')
Expand Down
5 changes: 5 additions & 0 deletions DependencyInjection/DoctrineExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ protected function ormLoad(array $config, ContainerBuilder $container)
$controllerResolverDefaults['disabled'] = true;
}

if ($config['controller_resolver']['auto_mapping'] === null) {
trigger_deprecation('doctrine/doctrine-bundle', '2.12', 'The default value of "doctrine.orm.controller_resolver.auto_mapping" will be changed from `true` to `false`. Explicitly configure `true` to keep existing behaviour.');
$config['controller_resolver']['auto_mapping'] = true;
}

if (! $config['controller_resolver']['auto_mapping']) {
$controllerResolverDefaults['mapping'] = [];
}
Expand Down
13 changes: 13 additions & 0 deletions UPGRADE-2.12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
UPGRADE FROM 2.11 to 2.12
========================

Configuration
-------------

### Controller resolver auto mapping default configuration will be changed

The default value of `doctrine.orm.controller_resolver.auto_mapping` will be changed from `true` to `false` in 3.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.

If you are relying on this functionality, you will need to configure it explicitly to silence the deprecation notice.
11 changes: 11 additions & 0 deletions UPGRADE-3.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
UPGRADE FROM 2.x to 3.0
=======================

Configuration
-------------

### Controller resolver auto mapping default configuration changed

The default value of `doctrine.orm.controller_resolver.auto_mapping` has changed from `true` to `false`.

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 were relying on this functionality, you will need to explicitly configure this now.

Types
-----

Expand Down

0 comments on commit 1a3b650

Please sign in to comment.