-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How use the @Groups ? #314
Comments
You shouldn't serialize entity, it's done by FOSRestBundle
Or even use |
Thanks for to reply @wiistriker . The method setSerializerGroups is in the class FOS\RestBundle\Controller\Annotations\View. So? .. How can I use the method setSerializerGroups... ? I tried this in my controller:
But I get the entity with all fields... |
Have a look at the Exclusion Policy option. Acme\\DemoBundle\\Entity\\Channel:
exclusion_policy: ALL
properties:
id:
expose: true
groups: ["channel_list", "channel_show"]
title:
expose: true
groups: ["channel_show"]
# ... |
@Chrysweel The |
@Chrysweel Set the serialization context in your View instance: // This is the context you created in your code above when serializing by hand
$context = SerializationContext::create()->setGroups(array('list'));
$view = // ...
$view->setSerializationContext($context);
return $this->handleView($view); |
Ok. issue solved. Thank you very much @stof. Also issue closed FriendsOfSymfony/FOSRestBundle#521 (comment) |
Hello.
I have problems with this issue.. I want to serialize an entity and only show some fields.
My entity:
And in My controller:
But my problem is the following:
I think that this code is serialize twice... because my result is:
And the solution correct is:
Somebody can help me ? Thanks :)
The text was updated successfully, but these errors were encountered: