-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Recursive denormalization does not support object_to_populate #21669
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
Well this wasn't immediately obvious, but I found this: which lead me to install the ProperyInfo compoment and enable it in my
This mostly fixes my problem(s). It does support recursion, and it does support groups, however, it does not support |
There is a lack in the documentation about how you need to activate PropertyInfo in order to have embedded object deserialized, I've already posted an issue about that: symfony/symfony-docs#7387 About the third problem (now only problem), object_to_populate is used to update/use an already existing object instead of creating a new one. You say that if the parent use this option, the embedded objects should used it too. I can see the need to use an existing object as value of a property, but:
|
@davidbarratt's comment helped me figure-out that I needed to install the |
…on object_to_populate (jewome62) This PR was squashed before being merged into the 4.3-dev branch (closes #30607). Discussion ---------- [Serializer] Add Support of recursive denormalization on object_to_populate | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | Pending | Fixed tickets | #21669 | License | MIT | Doc PR | Pending Currently the deserialization re-create new sub-object with object_to_populate. This option permit to make object_to_populate recursive. Commits ------- 5b72386 [Serializer] Add Support of recursive denormalization on object_to_populate
It would be really helpful if there was a way to recursively deseriailize objects.Given an object like this:
The serializer throws aSymfony\Component\Serializer\Exception\UnexpectedValueException
with the message "Expected argument of type 'Name', 'array' given" because it passes an array intosetName()
rather than running the denormilization on theName
class and then passing the result intosetName()
. I think having this feature would be really helpful. I could of course allow this method to accept Name and array, but then it will bypass:Populating the existing name objectAny groups that may be used for access.Since the method already has a typehint of the only thing it will accept (a class) I think it makes sense that if a non-scalar type hint is encountered in a setter, it should:Run the denormalizer with the type hinted class as the type.Pass the same groups from the parent to the childobject_to_populate
(assumingobject_to_populate
was set on the parent)The text was updated successfully, but these errors were encountered: