您好,我想动态更改我的序列化上下文的组。
编码 :
/**
* @Rest\Get("", name="bap_api_space_query")
* @Rest\View(serializerGroups={"Default", "space_dashboard", "dashboard_resource"})
*
* @ApiDoc(resource=true,description="List all spaces this user has access to")
*/
public function queryAction(Request $request)
{
$user = $this->getUser()->reload();
$organization = $user->getOrganization();
// depending the request, remove or add serialized group
// for example $view->setSerializationGroups('dashboard');
return $organization->getSpaces();
}
如代码中所述,我想在控制器中删除或添加组。有没有办法做到这一点?