Skip to content

[JsonEncoder] Add object to normalize method #59281

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

Closed
wants to merge 1 commit into from

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Dec 22, 2024

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

When normalizing a property, the whole object is sometimes useful.

For example, in API Platform if we want to convert resource ID to an IRI, we'll have to use https://github.com/api-platform/core/blob/main/src/Metadata/IriConverterInterface.php#L46 which needs the whole resource to gather some data and create the IRI.

@chalasr
Copy link
Member

chalasr commented Dec 22, 2024

This rather complicates the normalizer API so allow me to ask: do we really want this conceptually? Do we already know about use cases other than the IRIConverter? If not, could it be solved otherwise in API Platform?

@mtarld
Copy link
Contributor Author

mtarld commented Dec 23, 2024

After rethinking it, I agree with you. This should be delegated to a precedent step (such as a mapping step). Having the object here will unexpectedly allow the user to change the object data during the normalization step.

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

Successfully merging this pull request may close these issues.

3 participants