[英]How to extend symfony entity in bundle
Is there a way I can extend a symfony entity in another bundle using @DiscriminatorMap
without having to specify it beforehand?有没有一种方法可以使用
@DiscriminatorMap
在另一个包中扩展 symfony 实体,而无需事先指定它?
BundleA捆绑A
AbstractQueueItem
which is a MappedSuperclass
forAbstractQueueItem
这是一个MappedSuperclass
Event
which is extended byEvent
CreateEvent
and DeleteEvent
as Single Table Inheritene
or Class Table Inheritence
CreateEvent
和DeleteEvent
作为Single Table Inheritene
或Class Table Inheritence
BundleB捆绑B
UpdateEvent
) to the Event
-hierarchy without modifing BundleA
?BundleA
的情况下将新事件(即UpdateEvent
)添加到Event
层次结构?You can try letting doctrine auto-generate the discriminator map.您可以尝试让 doctrine 自动生成鉴别器 map。
From the last bullet point in this section of the docs :从文档本节的最后一个要点:
If no discriminator map is provided, then the map is generated automatically.
如果没有提供判别器 map,则自动生成 map。 The automatically generated discriminator map contains the lowercase short name of each class as key.
自动生成的鉴别器 map 包含每个 class 的小写短名称作为键。 So you would:
所以你会:
@DiscriminatorMap
declaration in BundleA.@DiscriminatorMap
声明。 EDIT编辑
As pointed out by ju_ in the comments, this solution will apparently not work with Doctrine ORM 3.0, but should still be valid for versions 2.5 - 2.7正如 ju_ 在评论中指出的那样,此解决方案显然不适用于 Doctrine ORM 3.0,但仍应适用于2.5 - 2.7版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.