8000 [DoctrineBridge] Attribute notation for entity in bundles is not recognized · Issue #43753 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DoctrineBridge] Attribute notation for entity in bundles is not recognized #43753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cinamo opened this issue Oct 26, 2021 · 0 comments · Fixed by #43754
Closed

[DoctrineBridge] Attribute notation for entity in bundles is not recognized #43753

cinamo opened this issue Oct 26, 2021 · 0 comments · Fixed by #43754

Comments

@cinamo
Copy link
Contributor
cinamo commented Oct 26, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0