Skip to content

Commit a4c341b

Browse files
committed
Allow configuring class names through methods instead of class parameters
1 parent dc8d470 commit a4c341b

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-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: 17 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,20 @@ abstract protected function getMappingResourceConfigDirectory();
434434
*/
435435
abstract protected function getMappingResourceExtension();
436436

437+
/**
438+
* The class name used by the various mapping drivers.
439+
*
440+
* @param string $driverType
441+
*
442+
* @return string
443+
*/
444+
protected function getMetadataDriverClass($driverType)
445+
{
446+
@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.', __METHOD__, static::class), E_USER_DEPRECATED);
447+
448+
return '%' . $this->getObjectManagerElementName('metadata.' . $driverType . '.class%');
449+
}
450+
437451
/**
438452
* Search for a manager that is declared as 'auto_mapping' = true.
439453
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy