Open keyermann opened 10 years ago
@willdurand @adrienbrault I've come up with this issue too, and haven't found a solution in any of the open / closed issues.
I think this is the same problem that the user had in #140 but he never replied.
The main problem is that when using serializer library to display only group attributes, _links
attribute is not shown. Not sure if this is a bug, or some documentation is missing.
Any thoughts?
Cheers!
You need to add the groups to those relations (they are excluded the same way the properties are excluded).
On Thursday, July 3, 2014, Pablo Martelletti notifications@github.com wrote:
@willdurand https://github.com/willdurand @adrienbrault https://github.com/adrienbrault I've come up with this issue too, and haven't found a solution in any of the open / closed issues.
I think this is the same problem that the user had in #140 https://github.com/willdurand/Hateoas/issues/140 but he never replied.
The main problem is that when using serializer library to display only group attributes, _links attribute is not show. Not sure if this is a bug, or some documentation is missing.
Any thoughts?
Cheers!
— Reply to this email directly or view it on GitHub https://github.com/willdurand/Hateoas/issues/159#issuecomment-48010495.
@adrienbrault what do yo mean by add the groups to the relation?
Talking about annotations, I would add a property to the group, by doing something like:
/**
* @var DateTime $startDate
* @ORM\Column(name="start_date", type="date")
* @Groups({"list", "details"})
*/
protected $startDate;
However, I define a relation for an Entity the following way:
* Class PlanAssignment
*
* @ORM\Entity
* @ORM\Table(name="aaa_plan_assignment")
* @ORM\Entity()
* @Hateoas\Relation(
* "self",
* href = @Hateoas\Route("aaa_asuser_plan_assignment_detail", parameters = {"id" = "expr(object.getId())"})
* )
*/
class PlanAssignment
So, with that example, what do you mean to add the group to the relation? the only "group" option in the documentation is for "exclusion" property, and in fact, I do no want to exclude but to show it (one would think that by default, all _links
would be shown and I would need to exclude them for groups, according to the "exclusion" property in Relation).
@adrienbrault ah! solved it. The key "exclusion" is confusing. I thought that those groups would be "excluded" from serialization, not the other way round. Sorry for that!
Aw ! Shame on me... I haven't thought a second about exclusion groups...
Thank you both @pmartelletti and @adrienbrault !!
Maybe we should rename exclusion to inclusion, I see it is really confusing.
On Thursday, July 3, 2014, Kévin EYERMANN notifications@github.com wrote:
Aw ! Shame on me... I haven't thought a second about exclusion groups...
Thank you both @pmartelletti https://github.com/pmartelletti and @adrienbrault https://github.com/adrienbrault !!
— Reply to this email directly or view it on GitHub https://github.com/willdurand/Hateoas/issues/159#issuecomment-48012795.
@adrienbrault not really, because the "exlude if" attribute "excludes", it does not includes.
Maybe a better idea would be to include _links
by default on all groups, and that the groups
attribute on exclusion
would list the groups on which the relation won't be shown. At least, that was the behavior I was expecting from the name of the attributes.
Actually you have to specify "Default" and "list" (or "details") in your context for the feature to work as expected, or you will experience strange behaviors.
If you use the FoSRestBundle , add annotations in the serialization controller Default group to see _links and _embedded
@Rest\View(serializerGroups={"Default"})
Hi.
Fist of all, sorry for my bad english, I'm trying to improve it. I don't know what I am doing wrong but I can't have any link in my results. Here are some peace of my work. Maybe you coult tell me the problem.
config.yml
StationModel.php
Station.php
serializer configuration
Result of a request :
Any Idea ? Something I didn't understand ?