简体   繁体   English

覆盖Child Bundle中的Doctrine Mappgins

[英]Override Doctrine Mappgins in the Child Bundle

Is there a way to override Doctrine mappings for some entity in the child bundle. 有没有办法覆盖子包中某些实体的Doctrine映射。

I have parent entity which is in third party bundle, it has softdeleatable extension enabled, I would like to disable that. 我有第三方包中的父实体,它启用了softdeleatable扩展,我想禁用它。

So, in third party bundle there is: 因此,在第三方包中有:

<gedmo:soft-deleteable field-name="deletedAt" />

Is there a way to override/disable that in my child bundle without changing third party code and still keep parent entity functionality? 有没有办法在我的子包中覆盖/禁用它而不更改第三方代码并仍保留父实体功能?

The only way to do it is to extend the parent entity and to write the whole mapping yourself. 唯一的方法是扩展父实体并自己编写整个映射。 Using external mapping — not annotations — is the way. 使用外部映射 - 而不是注释 - 就是这样。

One of possible solutions could be override entity metaclass mapping via EventListener . 一种可能的解决方案是通过EventListener覆盖实体元类映射。

See an example here: Symfony 2 + Doctrine 2 overriding entity configuration 请参阅此处的示例: Symfony 2 + Doctrine 2覆盖实体配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM