我试图通过 jmsserializer 在 pre_deserialization 上执行我的 Document 的 __constructor,但我不知道它为什么不起作用。
我正在从 yaml 文件中加载序列化程序元数据,如下所示:
AppBundle\Document\Campaign:
exclusion_policy: ALL
xml_root_name: campaign
properties:
id:
type: string
expose: true
slug:
type: string
expose: true
name:
type: string
expose: true
callback_methods:
pre_deserialize: [__construct]
当我尝试反序列化执行时:
$object = $serializer->deserialize($jsonString, 'AppBundle\\Document\\Campaign', 'json');
我无法访问构造函数,但是如果我将事件更改为任何其他可用的事件(pre_serialize、post_serialize 和 post_deserialize),我会这样做。
我认为缺少有关处理此特定事件的代码,但尝试复制相同的代码会影响它仍然无法正常工作的其他事件。看起来它从未在事件调度程序或类似的东西中注册。
我的环境是:
symfony 2.6.3
jms/serializer 0.16.0
jms/serializer-bundle 0.13.0
谢谢。