Getting a “true” object from a proxy object in doctrine2

前端 未结 11 1624
南笙
南笙 2021-02-01 13:50

Doctrine uses proxy objects to represent related objects in order to facilitate lazy loading. This is a really cool feature, but its causing an issue with something I am trying

11条回答
  •  无人共我
    2021-02-01 14:34

    The Symfony PropertyNormalizer gets around this issue using the ReflectionClass getParent method. If you need to inspect the object, as for a normalizer, rather than just use the ->get methods, you should be able to use a similar approach.

    It appears the Proxy has a parent of the actual entity, which is why instanceof still works.

提交回复
热议问题