Given the following entity hierachy:
// in main project src/Entity
#[ORM\Entity]
class Article extends AbstractArticle
// in bundle src/Entity/Content
#[ORM\MappedSuperclass]
abstract class AbstractArticle extends AbstractEntity
// in bundle src/Entity
#[ORM\MappedSuperclass]
abstract class AbstractEntity implements NormalizableInterface, EntityInterface
And this configuration:
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
XyBundle:
is_bundle: true
type: annotation
dir: 'Entity'
prefix: 'XyBundle\Entity'
alias: Xy
I'm getting this error:
Class "App\Entity\Article" sub class of "XyBundle\Entity\Content\AbstractArticle" is not a valid entity or mapped super class.
I want to instantiate one or more different articles of the abstract article in the future. Yet, this configuration works if and only if I put #[ORM\Entity]
to the AbstractArticle class.
What am I doing wrong here?
I backtracked the issue to the point that I had to change the mapping type to attribute
instead of annotation
. It works now.