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

Appearance settings

Commit 25483b0

Browse filesBrowse files
committed
bug #47798 [DoctrineBridge] Fix auto mapping for bundles that contain only embeddables (jorissae)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [DoctrineBridge] Fix auto mapping for bundles that contain only embeddables | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #47791 | License | MIT | Doc PR | N/A Commits ------- e8c8f4e [DoctrineBridge] Fix auto mapping for bundles that contain only embeddables
2 parents 1d07035 + e8c8f4e commit 25483b0
Copy full SHA for 25483b0

File tree

Expand file treeCollapse file tree

6 files changed

+132
-2
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+132
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,16 @@ private function detectMappingType(string $directory, ContainerBuilder $containe
311311
foreach ($glob as $file) {
312312
$content = file_get_contents($file);
313313

314-
if (preg_match('/^#\[.*'.$quotedMappingObjectName.'\b/m', $content)) {
314+
if (
315+
preg_match('/^#\[.*'.$quotedMappingObjectName.'\b/m', $content) ||
316+
preg_match('/^#\[.*Embeddable\b/m', $content)
317+
) {
315318
break;
316319
}
317-
if (preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content)) {
320+
if (
321+
preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content) ||
322+
preg_match('/^ \* @.*Embeddable\b/m', $content)
323+
) {
318324
$type = 'annotation';
319325
break;
320326
}

‎src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ public function testUnrecognizedCacheDriverException()
279279
public function providerBundles()
280280
{
281281
yield ['AnnotationsBundle', 'annotation', '/Entity'];
282+
yield ['FullEmbeddableAnnotationsBundle', 'annotation', '/Entity'];
282283
if (\PHP_VERSION_ID >= 80000) {
283284
yield ['AttributesBundle', 'attribute', '/Entity'];
285+
yield ['FullEmbeddableAttributesBundle', 'attribute', '/Entity'];
284286
}
285287
yield ['XmlBundle', 'xml', '/Resources/config/doctrine'];
286288
yield ['PhpBundle', 'php', '/Resources/config/doctrine'];
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fixtures\Bundles\FullEmbeddableAnnotationsBundle\Entity;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Embeddable;
16+
use Doctrine\ORM\Mapping\Id;
17+
18+
/**
19+
* @Embeddable
20+
*/
21+
class Address
22+
{
23+
24+
/** @Column(type="string") */
25+
public $street;
26+
27+
/** @Column(type="string") */
28+
public $zipCode;
29+
30+
/** @Column(type="string") */
31+
public $city;
32+
33+
public function __construct($street, $zipCode, $city)
34+
{
35+
$this->street = $street;
36+
$this->zipCode = $zipCode;
37+
$this->city = $city;
38+
}
39+
40+
public function __toString(): string
41+
{
42+
return sprintf('%s %s %s', $this->street, $this->zipCode, $this->city);
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fixtures\Bundles\FullEmbeddableAnnotationsBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class FullEmbeddableAnnotationsBundle extends Bundle
17+
{
18+
}
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fixtures\Bundles\FullEmbeddableAttributesBundle\Entity;
13+
14+
use Doctrine\ORM\Mapping\Column;
15+
use Doctrine\ORM\Mapping\Embeddable;
16+
use Doctrine\ORM\Mapping\Id;
17+
18+
#[Embeddable]
19+
class Address
20+
{
21+
22+
#[Column(type: 'string')]
23+
public $street;
24+
25+
#[Column(type: 'string')]
26+
public $zipCode;
27+
28+
#[Column(type: 'string')]
29+
public $city;
30+
31+
public function __construct($street, $zipCode, $city)
32+
{
33+
$this->street = $street;
34+
$this->zipCode = $zipCode;
35+
$this->city = $city;
36+
}
37+
38+
public function __toString(): string
39+
{
40+
return sprintf('%s %s %s', $this->street, $this->zipCode, $this->city);
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Fixtures\Bundles\FullEmbeddableAttributesBundle;
13+
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class FullEmbeddableAttributesBundle extends Bundle
17+
{
18+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.