it happens lots of time we wanna serialize a sub set of properties , just like this, it also happens we need to change name of serialized name of property in different group. may it will be better if we can do this:
/**
* @Expose
* @SerializedName("text",{"product_select_car_model"})
* @Groups({"product_select_car_model"})
*/
private $brandName;
this means when we serialize this entity in product_select_car_model group,change serialize property brandName to text.
Hi, I need it too. Have you found a solution ?
Thanks.
@redayoub , unfortunitely I have't , I will post it here if I do.
Hi guyz,
I need it too, Have you found a solution ?
see u.
Hello,
You can make a new getter for your property and use a virtual_property.
Here an exemple with lastname serialized in "lastname" and "name" in two groups.
/**
* @return string
*/
public function getNameForGroup2()
{
return $this->getLastname();
}
/**
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* @var string
*/
private $lastname;
virtual_properties:
getNameForGroup2:
serialized_name: name
expose: true
type: string
groups: ['group2']
properties:
lastname:
serialized_name: lastname
expose: true
type: string
groups: ['group1']
@psary looks good
Thanks :+1:
I am extending the entity(model) by another one and changing the accessType to public method. Unless you do have own naming strategy you can specify the new name and/or use groups. On second thought you may use Trait instead.
Most helpful comment
Hello,
You can make a new getter for your property and use a virtual_property.
Here an exemple with lastname serialized in "lastname" and "name" in two groups.