Skip to content

[Core/Serialization] Use correct ContextAwareNormalizerInterface #517

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

Merged
merged 1 commit into from
Jun 29, 2018

Conversation

paxal
Copy link
Contributor

@paxal paxal commented Jun 29, 2018

Related to : https://github.com/api-platform/docs/blob/2.2/core/serialization.md#changing-the-serialization-context-on-a-per-item-basis

The class used in custom normalization example implements NormalizerInterface but the supportsNormalization() method is the one from the ContextAwareNormalizerInterface, and it must be this one to access $context variable and avoid call loops.

This doc is very valuable, thanks !

Related to : https://github.com/api-platform/docs/blob/2.2/core/serialization.md#changing-the-serialization-context-on-a-per-item-basis

The class used in custom normalization example implements `NormalizerInterface` but the `supportsNormalization()` method is the one from the `ContextAwareNormalizerInterface`, and it must be this one to access `$context` variable and avoid call loops.
@dunglas dunglas merged commit d759422 into api-platform:2.2 Jun 29, 2018
@dunglas
Copy link
Member

dunglas commented Jun 29, 2018

Good catch, thanks @paxal

@paxal paxal deleted the patch-1 branch June 29, 2018 13:54
@paxal
Copy link
Contributor Author

paxal commented Jun 29, 2018

Thanks for this awesome documentation :)

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

Successfully merging this pull request may close these issues.

2 participants