Doctrine 2 LifecycleCallbacks with abstract base class are not called(不调用具有抽象基类的 Doctrine 2 LifecycleCallbacks)
问题描述
我有这种情况:
抽象类:
具体类:
然后我像这样在我的控制器中调用它:
Then i call it in my controller like this:
一切都按预期工作,因此抽象类中的 id 字段为 User 实体创建,我可以访问它等.问题是,永远不会到达死('这个点从未达到')"这一行.(注意@ORMPreUpdate)这意味着不会调用lifecycleCallbacks继承的对象.这是一个错误,还是有原因?
Everything works as expected, so the id field from the abstract class gets created for the User entity, i can access it etc. The problem is, that the line "die('THIS POINT IS NEVER REACHED')" is never reached. (Note the @ORMPreUpdate) This means that lifecycleCallbacks are not called on inherited objects. Is this a bug, or is there a reason for this?
推荐答案
您的抽象基类必须被注释为映射超类,并包含 HasLifecycleCallbacks-注释.
Your abstract base class has to be anotated as Mapped Superclasses and include the HasLifecycleCallbacks-Annotation.
更多信息:教义文档中的继承映射.
这篇关于不调用具有抽象基类的 Doctrine 2 LifecycleCallbacks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!