4

I've a custom User Class which extends from the FOSUser Model:

use FOS\UserBundle\Model\User as BaseUser;
use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\Expose;

/**
 * @ExclusionPolicy("all")
 */
class User extends BaseUser

My problem is: The Abstract properties from the FOSUser Model are exposed, but the properties in the custom extended class not.

To expose the properties I've two yaml files: 1) MyBundle/../Resources/config/serializer/fos/Model.User.yml 2) SecurityBundle/../Resource/config/serializer/Entity.User.yml

My custom User class has a property $name. Which should be exposed by my .yaml file:

ErwineEberhard\SecurityBundle\Entity\User:
    exclusion_policy: none
    properties:
        name:
            expose: true
            groups: [list, details]

Doctrine compels me to add a $id in the exteded class. The $id is only exposed when I add * @ExclusionPolicy("all") in my custom User class. When I add @Expose to name, no differences.

How to accomplish this?

erwineberhard
  • 309
  • 4
  • 17
  • You should use only one configuration (annotation, xml or yaml), not both. And after each change you should remove content of ``cache`` directory (cause mostly it doesn't refresh after change in serialization configuration) – Przemysław Piechota. kibao Oct 07 '14 at 19:05
  • When I remove `@ExclusionPolicy("all")`, the id is also not exposed. – erwineberhard Oct 08 '14 at 12:30
  • Answered here: http://stackoverflow.com/questions/12960141/jmsserializerbundle-no-control-over-third-party-meta-data/12961994#12961994 – hanego Mar 05 '15 at 00:53

0 Answers0