So I have a response class like this (simplified snippet):
/**
* @Serializer\ExclusionPolicy("all")
*/
class MyResponse
{
/**
* @Serializer\Expose
* @Serializer\Groups({"myGroup"})
* @Serializer\Accessor("getMyName")
*/
public $name;
public function getMyName()
{
return 'Donald';
}
}
The exclusion policy excludes all fields from being serialized unless they're explicitly exposed with @Serializer\Expose
and the data group is a match.
This is working perfectly for all fields, except those with the @Serializer\Accessor
annotation. These fields are always being included, regardless of group policy. I can't find anything in the docs or any other reports to suggest that the @Serializer\Accessor
annotation overrides group policy, nor any way to manually check the data group within the accessor function.
Is there a way to accomplish this, or will I have to inline all my accessor functions in the response constructor? I was trying to avoid having a huge 100L+ constructor function, but it defeats the point of using the accessor annotation if I can't exclude certain fields...