Skip to content
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

Embedded relation should inherit exclusion #164

Closed
sroze opened this issue Jul 19, 2014 · 1 comment
Closed

Embedded relation should inherit exclusion #164

sroze opened this issue Jul 19, 2014 · 1 comment

Comments

@sroze
Copy link

sroze commented Jul 19, 2014

When I set groups in the exclusion strategy of a relation, the embedded is never generated.

/**
 * @Hateoas\Relation(
 *     "user",
 *     href = "expr('/api/user/' ~ object.getUser().getId())",
 *     embedded = "expr(object.getUser())",
 *     exclusion = @Hateoas\Exclusion(
 *         excludeIf = "expr(object.getUser() === null)",
 *         groups={"travel"}
 *     )
 * )
 */

It's because the ExclusionManager call the shouldSkipProperty method of JMS's GroupsExclusionStrategy with the embedded exclusion. In that case, the exclusion of embedded is empty, so these tests fail, so this relation is not embedded.

The only way to make it working is to repeat the exclusion on the embedded:

/**
 * @Hateoas\Relation(
 *     "user",
 *     href = "expr('/api/user/' ~ object.getUser().getId())",
 *     embedded = @Hateoas\Embedded(
 *         "expr(object.getUser())",
 *         exclusion = @Hateoas\Exclusion(
 *             groups={"travel"}
 *         )
 *     ),
 *     exclusion = @Hateoas\Exclusion(
 *         excludeIf = "expr(object.getUser() === null)",
 *         groups={"travel"}
 *     )
 * )
 */

That's why I think that embedded should inherit from relation exclusion when there's no specified on it.

@adrienbrault
Copy link
Contributor

This makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants