Serializing Entity Relation only to Id with JMS Serializer

后端 未结 6 613
温柔的废话
温柔的废话 2021-02-02 09:54

I\'m trying to serialize a entity relation with JMS Serializer.

Here is the Entity:

class Ad
{ 

    /**
     * @Type(\"string\")
     * @Groups({\"manag         


        
6条回答
  •  萌比男神i
    2021-02-02 10:24

    You can use @Type and @Accessor annotations:

    /**
     * @Type("string") 
     * @Accessor(getter="serializeType",setter="setType") 
     */
    protected $type;
    public function serializeType()
    {   
      return $this->type->getId();
    }
    

提交回复
热议问题