Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5fb8713

Browse files
committed
Allow AbstractDoctrineExtension implementations to support the newer bundle structure
1 parente227a52 commit5fb8713

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

‎UPGRADE-5.4.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
UPGRADE FROM 5.3 to 5.4
22
=======================
33

4+
DoctrineBridge
5+
--------------
6+
7+
* Add argument`$bundleDir` to`AbstractDoctrineExtension::loadMappingInformation()`
8+
* Add argument`$bundleDir` to`AbstractDoctrineExtension::getMappingResourceConfigDirectory()`
9+
410
Cache
511
-----
612

‎UPGRADE-6.0.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ DoctrineBridge
1010
--------------
1111

1212
* Remove`UserLoaderInterface::loadUserByUsername()` in favor of`UserLoaderInterface::loadUserByIdentifier()`
13+
* Add argument`$bundleDir` to`AbstractDoctrineExtension::loadMappingInformation()`
14+
* Add argument`$bundleDir` to`AbstractDoctrineExtension::getMappingResourceConfigDirectory()`
1315

1416
Cache
1517
-----

‎src/Symfony/Bridge/Doctrine/CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ CHANGELOG
77
* Add`DoctrineOpenTransactionLoggerMiddleware` to log when a transaction has been left open
88
* Deprecate`PdoCacheAdapterDoctrineSchemaSubscriber` and add`DoctrineDbalCacheAdapterSchemaSubscriber` instead
99
*`UniqueEntity` constraint retrieves a maximum of two entities if the default repository method is used.
10+
* Add support for the newer bundle structure to`AbstractDoctrineExtension::loadMappingInformation()`
11+
* Add argument`$bundleDir` to`AbstractDoctrineExtension::loadMappingInformation()`
12+
* Add argument`$bundleDir` to`AbstractDoctrineExtension::getMappingResourceConfigDirectory()`
1013

1114
5.3
1215
---

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
7373

7474
if ($mappingConfig['is_bundle']) {
7575
$bundle =null;
76+
$bundleMetadata =null;
7677
foreach ($container->getParameter('kernel.bundles')as$name =>$class) {
7778
if ($mappingName ===$name) {
7879
$bundle =new \ReflectionClass($class);
80+
$bundleMetadata =$container->getParameter('kernel.bundles_metadata')[$name];
7981

8082
break;
8183
}
@@ -85,7 +87,7 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
8587
thrownew \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled.',$mappingName));
8688
}
8789

88-
$mappingConfig =$this->getMappingDriverBundleConfigDefaults($mappingConfig,$bundle,$container);
90+
$mappingConfig =$this->getMappingDriverBundleConfigDefaults($mappingConfig,$bundle,$container,$bundleMetadata['path']);
8991
if (!$mappingConfig) {
9092
continue;
9193
}
@@ -133,11 +135,21 @@ protected function setMappingDriverConfig(array $mappingConfig, string $mappingN
133135
*
134136
* Returns false when autodetection failed, an array of the completed information otherwise.
135137
*
138+
* @param string $bundleDir The bundle directory path
139+
*
136140
* @return array|false
137141
*/
138-
protectedfunctiongetMappingDriverBundleConfigDefaults(array$bundleConfig,\ReflectionClass$bundle,ContainerBuilder$container)
142+
protectedfunctiongetMappingDriverBundleConfigDefaults(array$bundleConfig,\ReflectionClass$bundle,ContainerBuilder$container/* , string $bundleDir = null */)
139143
{
140-
$bundleDir =\dirname($bundle->getFileName());
144+
$args =\func_get_args();
145+
146+
if (\func_num_args() <4) {
147+
trigger_deprecation('symfony/doctrine-bridge','5.4','The "%s()" method will have a new "string $bundleDir = null" argument in version 6.0, not defining it is deprecated.',__METHOD__);
148+
149+
$bundleDir =\dirname($bundle->getFileName());
150+
}else {
151+
$bundleDir =$args[3];
152+
}
141153

142154
if (!$bundleConfig['type']) {
143155
$bundleConfig['type'] =$this->detectMetadataDriver($bundleDir,$container);
@@ -152,7 +164,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
152164
if (\in_array($bundleConfig['type'], ['annotation','staticphp','attribute'])) {
153165
$bundleConfig['dir'] =$bundleDir.'/'.$this->getMappingObjectDefaultName();
154166
}else {
155-
$bundleConfig['dir'] =$bundleDir.'/'.$this->getMappingResourceConfigDirectory();
167+
$bundleConfig['dir'] =$bundleDir.'/'.$this->getMappingResourceConfigDirectory($bundleDir);
156168
}
157169
}else {
158170
$bundleConfig['dir'] =$bundleDir.'/'.$bundleConfig['dir'];
@@ -440,9 +452,11 @@ abstract protected function getMappingObjectDefaultName();
440452
/**
441453
* Relative path from the bundle root to the directory where mapping files reside.
442454
*
455+
* @param string $bundleDir The bundle directory path
456+
*
443457
* @return string
444458
*/
445-
abstractprotectedfunctiongetMappingResourceConfigDirectory();
459+
abstractprotectedfunctiongetMappingResourceConfigDirectory(/* string $bundleDir = null */);
446460

447461
/**
448462
* Extension used by the mapping files.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp