[英]Cannot override serializer config in SonataUserBundle to hide properties
I am using SonataUserBundle and JMSSerializerBundle and I would like to hide the token and other properties of my serialized object.我正在使用SonataUserBundle和JMSSerializerBundle ,我想隐藏我的序列化对象的令牌和其他属性。
The file I want to ovvride in SonataUserBundle is Resources/config/serializer/Model.User.xml .我想在 SonataUserBundle 中ovvride的文件是Resources/config/serializer/Model.User.xml 。
Here is my configuration:这是我的配置:
app/config.yml应用程序/config.yml
jms_serializer: metadata: auto_detection: true directories: - { path: %kernel.root_dir%/Resources/SoantaUserBundle/serializer, namespace_prefix: 'Sonata\\UserBundle' } - { path: %kernel.root_dir%/Resources/FOSUserBundle/serializer, namespace_prefix: 'FOS\\UserBundle' }
and in app/Resources/SonataUserBundle/serializer I have tried 2 files.在app/Resources/SonataUserBundle/serializer 中,我尝试了 2 个文件。
Model.User.xml模型.用户.xml
<?xml version="1.0" encoding="UTF-8"?> <serializer> <class name="Sonata\\UserBundle\\Model\\User" exclusion-policy="all" xml-root-name="user"> <property name="token" type="string" expose="false" since-version="1.0" groups="sonata_api_read,sonata_api_write,sonata_search" /> </class> </serializer>
Model.User.yml模型.用户.yml
Sonata\\UserBundle\\Model\\User: exclusion_policy: ALL properties: token: expose: false
Both files dont seem to work.这两个文件似乎都不起作用。
I have managed to hide some properties from the FOSUserBundle , but seems I have troubles hiding the ones related to SonataUserBundle .我设法从FOSUserBundle隐藏了一些属性,但似乎我在隐藏与SonataUserBundle相关的属性时遇到了麻烦。 I'm not sure if it's relevant but I would like to mention that I am using also am using HWIOauthBundle .
我不确定它是否相关,但我想提一下,我也在使用HWIOauthBundle 。
Any help will be greatly appreciated.任何帮助将不胜感激。
First, I don't think you need autodetection since you're specifying also the directories.首先,我认为您不需要自动检测,因为您还指定了目录。 Then you have a couple of typos in the sonata directory path:
然后你在奏鸣曲目录路径中有几个拼写错误:
jms_serializer:
metadata:
directories:
- { path: %kernel.root_dir%/Resources/SonataUserBundle/serializer, namespace_prefix: 'Sonata\UserBundle' }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.