Skip to content

Commit 9b3b25a

Browse files
committedMay 23, 2023
Add a new report_fields_where_declared config setting
This adds a new config setting `report_fields_where_declared` that shall make it easier for users to address a deprecation added in Doctrine ORM 2.16, more specifically in doctrine/orm#10455. I think that since this bundle allows to specify the mapping configuration per entity manager, it would make sense to have this new config setting at the entity manager level as well.
1 parent e6da248 commit 9b3b25a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
 

‎DependencyInjection/Configuration.php

+1
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ private function getOrmEntityManagersNode(): ArrayNodeDefinition
628628
->arrayNode('schema_ignore_classes')
629629
->prototype('scalar')->end()
630630
->end()
631+
->scalarNode('report_fields_where_declared')->defaultFalse()->end()
631632
->end()
632633
->children()
633634
->arrayNode('second_level_cache')

‎DependencyInjection/DoctrineExtension.php

+16
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,22 @@ protected function loadOrmEntityManagerMappingInformation(array $entityManager,
820820
$this->loadMappingInformation($entityManager, $container);
821821
$this->registerMappingDrivers($entityManager, $container);
822822

823+
$chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($entityManager['name'] . '_metadata_driver'));
824+
foreach (array_keys($this->drivers) as $driverType) {
825+
$mappingService = $this->getObjectManagerElementName($entityManager['name'] . '_' . $driverType . '_metadata_driver');
826+
$mappingDriverDef = $container->getDefinition($mappingService);
827+
$args = $mappingDriverDef->getArguments();
828+
if ($driverType === 'annotation') {
829+
$args[2] = $entityManager['report_fields_where_declared'];
830+
} elseif ($driverType === 'attribute') {
831+
$args[1] = $entityManager['report_fields_where_declared'];
832+
} else {
833+
continue;
834+
}
835+
836+
$mappingDriverDef->setArguments($args);
837+
}
838+
823839
$ormConfigDef->addMethodCall('setEntityNamespaces', [$this->aliasMap]);
824840
}
825841

‎Tests/DependencyInjection/AbstractDoctrineExtensionTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
499499
[
500500
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AttributesBundle' . DIRECTORY_SEPARATOR . 'Entity',
501501
],
502+
false
502503
]);
503504

504505
$ymlDef = $container->getDefinition('doctrine.orm.default_yml_metadata_driver');
@@ -554,6 +555,7 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
554555
[
555556
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
556557
],
558+
false
557559
]);
558560

559561
$ymlDef = $container->getDefinition('doctrine.orm.em2_yml_metadata_driver');

0 commit comments

Comments
 (0)