Skip to content

Commit fa20b37

Browse files
Remove controller resolver auto mapping configuration
Remove controller resolver auto mapping configuration as discussed in doctrine#1804.
1 parent cb2ad28 commit fa20b37

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

UPGRADE-3.1.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
UPGRADE FROM 3.0 to 3.1
2+
=======================
3+
4+
Configuration
5+
-------------
6+
7+
### `doctrine.orm.controller_resolver.auto_mapping` option deprecated
8+
9+
The `doctrine.orm.controller_resolver.auto_mapping` only accepted `false` as value since 3.0 and supplying the value explicitly is now marked as deprecated.

UPGRADE-4.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
UPGRADE FROM 3.x to 4.0
2+
=======================
3+
4+
Configuration
5+
-------------
6+
7+
### `doctrine.orm.controller_resolver.auto_mapping` option has been removed
8+
9+
The `doctrine.orm.controller_resolver.auto_mapping` only accepted `false` as value since 3.0 and is now removed.

src/DependencyInjection/Configuration.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,12 @@ private function addOrmSection(ArrayNodeDefinition $node): void
523523
->canBeDisabled()
524524
->children()
525525
->booleanNode('auto_mapping')
526-
->defaultNull()
527-
->info('Set to false to disable using route placeholders as lookup criteria when the primary key doesn\'t match the argument name')
526+
->defaultFalse()
527+
->validate()
528+
->ifTrue(static fn ($v) => $v !== false)
529+
->thenInvalid('The setting "controller_resolver.auto_mapping" can no longer be enabled and must be set to false')
530+
->end()
531+
->info('Set to true to enable using route placeholders as lookup criteria when the primary key doesn\'t match the argument name')
528532
->end()
529533
->booleanNode('evict_cache')
530534
->info('Set to true to fetch the entity from the database instead of using the cache, if any')

src/DependencyInjection/DoctrineExtension.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -505,19 +505,6 @@ protected function ormLoad(array $config, ContainerBuilder $container)
505505
$controllerResolverDefaults['disabled'] = true;
506506
}
507507

508-
if ($config['controller_resolver']['auto_mapping'] === null) {
509-
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.');
510-
$config['controller_resolver']['auto_mapping'] = true;
511-
}
512-
513-
if ($config['controller_resolver']['auto_mapping'] === true) {
514-
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.');
515-
}
516-
517-
if (! $config['controller_resolver']['auto_mapping']) {
518-
$controllerResolverDefaults['mapping'] = [];
519-
}
520-
521508
if ($config['controller_resolver']['evict_cache']) {
522509
$controllerResolverDefaults['evict_cache'] = true;
523510
}
@@ -527,7 +514,7 @@ protected function ormLoad(array $config, ContainerBuilder $container)
527514
null,
528515
null,
529516
null,
530-
$controllerResolverDefaults['mapping'] ?? null,
517+
null,
531518
null,
532519
null,
533520
null,

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,6 @@ public function testControllerResolver(bool $simpleEntityManagerConfig): void
14991499
$config['orm'] = [];
15001500
}
15011501

1502-
$config['orm']['controller_resolver'] = ['auto_mapping' => true];
15031502
$config['orm']['resolve_target_entities'] = ['Throwable' => 'stdClass'];
15041503

15051504
$extension->load([$config], $container);
@@ -1527,14 +1526,13 @@ public function testControllerResolver(bool $simpleEntityManagerConfig): void
15271526

15281527
$config['orm']['controller_resolver'] = [
15291528
'enabled' => false,
1530-
'auto_mapping' => false,
15311529
'evict_cache' => true,
15321530
];
15331531
$extension->load([$config], $container);
15341532

15351533
$container->setDefinition('controller_resolver_defaults', $container->getDefinition('doctrine.orm.entity_value_resolver')->getArgument(2))->setPublic(true);
15361534
$container->compile();
1537-
$this->assertEquals(new MapEntity(null, null, null, [], null, null, null, true, true), $container->get('controller_resolver_defaults'));
1535+
$this->assertEquals(new MapEntity(null, null, null, null, null, null, null, true, true), $container->get('controller_resolver_defaults'));
15381536
}
15391537

15401538
// phpcs:enable

tests/baseline-ignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
%"doctrine.orm.controller_resolver.auto_mapping" will be changed from `true` to `false`.%
2-
%Enabling the controller resolver automapping feature has been deprecated.%
31
%Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated.%

0 commit comments

Comments
 (0)