Skip to content

Commit ff26443

Browse files
authored
Detect bundle containing only MappedSuperclass annotations (#2171)
1 parent 0cf3392 commit ff26443

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/DependencyInjection/DoctrineExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,15 @@ private function detectMappingType(string $directory, ContainerBuilder $containe
422422
if (
423423
preg_match('/^#\[.*' . $quotedMappingObjectName . '\b/m', $content)
424424
|| preg_match('/^#\[.*Embeddable\b/m', $content)
425+
|| preg_match('/^#\[.*MappedSuperclass\b/m', $content)
425426
) {
426427
break;
427428
}
428429

429430
if (
430431
self::textContainsAnnotation($quotedMappingObjectName, $content)
431432
|| self::textContainsAnnotation('Embeddable', $content)
433+
|| self::textContainsAnnotation('MappedSuperclass', $content)
432434
) {
433435
$type = 'annotation';
434436
break;

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,7 @@ public function testControllerResolver(bool $simpleEntityManagerConfig): void
15111511
#[TestWith(['AttributesBundle', 'attribute'], 'Bundle with attributes')]
15121512
#[TestWith(['RepositoryServiceBundle', 'attribute'], 'Bundle with both')]
15131513
#[TestWith(['AnnotationsBundle', 'annotation'], 'Bundle with annotations')]
1514+
#[TestWith(['MappedSuperclassBundle', 'annotation'], 'Bundle with annotations containing only MappedSuperclass')]
15141515
#[TestWith(['AttributesWithPackageBundle', 'attribute'], 'Bundle with attributes and @package')]
15151516
public function testDetectMappingType(string $bundle, string $expectedType, string $vendor = '')
15161517
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Fixtures\Bundles\MappedSuperclassBundle\Entity;
6+
7+
/** @ORM\MappedSuperclass() */
8+
class TestAnnotationEntity
9+
{
10+
/**
11+
* @ORM\Id
12+
* @ORM\GeneratedValue(strategy="AUTO")
13+
* @ORM\Column(type="integer")
14+
*/
15+
public int|null $id = null;
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Fixtures\Bundles\MappedSuperclassBundle;
6+
7+
use Symfony\Component\HttpKernel\Bundle\Bundle;
8+
9+
class MappedSuperclassBundle extends Bundle
10+
{
11+
}

0 commit comments

Comments
 (0)