Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b53d8cc

Browse files
committed
[DoctrineBridge] Allow configuring class names through methods instead of class parameters
1 parent dc8d470 commit b53d8cc

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

UPGRADE-4.4.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ DoctrineBridge
7272
* Deprecated passing an `IdReader` to the `DoctrineChoiceLoader` when the query cannot be optimized with single id field.
7373
* Deprecated not passing an `IdReader` to the `DoctrineChoiceLoader` when the query can be optimized with single id field.
7474
* Deprecated `RegistryInterface`, use `Doctrine\Common\Persistence\ManagerRegistry`.
75+
* Added a new `getMetadataDriverClass` method to replace class parameters in `AbstractDoctrineExtension`. This method
76+
will be abstract in Symfony 5 and must be declared in extending classes.
7577

7678
Filesystem
7779
----------

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ DoctrineBridge
122122
* Passing an `IdReader` to the `DoctrineChoiceLoader` when the query cannot be optimized with single id field will throw an exception, pass `null` instead
123123
* Not passing an `IdReader` to the `DoctrineChoiceLoader` when the query can be optimized with single id field will not apply any optimization
124124
* The `RegistryInterface` has been removed.
125+
* Added a new `getMetadataDriverClass` method in `AbstractDoctrineExtension` to replace class parameters.
125126

126127
DomCrawler
127128
----------

src/Symfony/Bridge/Doctrine/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* added `DoctrineClearEntityManagerMiddleware`
88
* deprecated `RegistryInterface`, use `Doctrine\Common\Persistence\ManagerRegistry`
99
* added support for invokable event listeners
10+
* added `getMetadataDriverClass` method to deprecate class parameters in service configuration files
1011

1112
4.3.0
1213
-----

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ protected function registerMappingDrivers($objectManager, ContainerBuilder $cont
178178
if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'))) {
179179
$chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'));
180180
} else {
181-
$chainDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.driver_chain.class%'));
181+
$chainDriverDef = new Definition($this->getMetadataDriverClass('driver_chain'));
182182
$chainDriverDef->setPublic(false);
183183
}
184184

@@ -194,12 +194,12 @@ protected function registerMappingDrivers($objectManager, ContainerBuilder $cont
194194
}
195195
$mappingDriverDef->setArguments($args);
196196
} elseif ('annotation' == $driverType) {
197-
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
197+
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
198198
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
199199
array_values($driverPaths),
200200
]);
201201
} else {
202-
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
202+
$mappingDriverDef = new Definition($this->getMetadataDriverClass($driverType), [
203203
array_values($driverPaths),
204204
]);
205205
}
@@ -434,6 +434,16 @@ abstract protected function getMappingResourceConfigDirectory();
434434
*/
435435
abstract protected function getMappingResourceExtension();
436436

437+
/**
438+
* The class name used by the various mapping drivers.
439+
*/
440+
protected function getMetadataDriverClass(string $driverType): string
441+
{
442+
@trigger_error(sprintf('Not declaring the "%s" method in class "%s" is deprecated since Symfony 4.4. This method will be abstract in Symfony 5.0.', __METHOD__, static::class), E_USER_DEPRECATED);
443+
444+
return '%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%');
445+
}
446+
437447
/**
438448
* Search for a manager that is declared as 'auto_mapping' = true.
439449
*

0 commit comments

Comments
 (0)