-
-
Notifications
You must be signed in to change notification settings - Fork 912
Allow Constructors with Relationships #2169
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
Comments
This is the same issue as #2123 |
I've stopped working on this, because of lack of time. Now I've more time, so I'm planning PR for this to the end of this week. |
I agree. I can also merge PRs on the SF Serializer, don't hesitate to ping me on the Symfony slack! |
I think we can close this now that @komik966's changes have been merged. Thanks! |
Currently, Resource constructors will fail if they contain a relationship entity.
This is because the ItemNormalizer in API Platform only denormalizes a relationship entity on the
setAttributeValue
method call. However, theinstantiateObject
method call in the normalizer is done before the relationship value has been denormalized.I think this could be trivial to implement if we override the instantiateObject, check if any of the properties are relationships, and if so, we denormalize them ahead of time so that whether a value is set via setAttributeValue or instantiateObject, it will be denormalized properly.
Thoughts?
The text was updated successfully, but these errors were encountered: