-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Symfony version(s) affected
5.3
Description
When loading a bundle with a Doctrine entity, this entity is automatically recognized if auto_mapping: true
is set in the Doctrine DBAL configuration. If you use annotations (/** @ORM\Entity */
), this will work well. However, if you use the new Attributes to define the entity and its properties (#[ORM\Entity]
) this is not recognized by the DoctrineBridge.
How to reproduce
Create an entity in a bundle and define its Entity status with an attribute:
<?php
declare(strict_types=1);
namespace RedAnt\EventSourcingBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use RedAnt\EventSourcingBundle\Entity\Repository\ProjectionsRepository;
#[ORM\Entity(repositoryClass: ProjectionsRepository::class)]
final class ProjectionState
{
// ...
}
This entity class is then not picked up by the Doctrine schema upgrade tool.
Possible Solution
The AbstractDoctrineExtension in the DoctrineBridge already has a method for detecting the correct annotation type for entities in a folder (using a regex on the entity classes). We should separate this out into a new method detectMappingType
and also using it when detecting the metadataDriver for that bundle directory.
Additional Context
No response