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

create() logic for casting $data needs to accommodate multiple items #11

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Labels
Bug Something isn't working Enhancement New feature or request

Comments

@weierophinney
Copy link
Contributor

As reported on the mailing list, create() casts $data to an object if it is an array. This is useful to ensure that any changes a listener makes to $data will be reflected in the event for later listeners. However, it breaks one critical situation: when a user posts multiple entities at once (which will be an array of either arrays or objects).

The logic for this needs to be updated to accommodate both use cases. One possibility is to cast to an ArrayObject, but I'm unsure if that will address the "changes made in one listener will affect later listeners" use case (in the event that an item in the ArrayObject is an array, and that item is changed).


Originally posted by @weierophinney at zfcampus/zf-rest#51

@weierophinney weierophinney added Bug Something isn't working Enhancement New feature or request labels Dec 31, 2019
@weierophinney
Copy link
Contributor Author

👍

Is reasonable that if $data is a list then items in $data are casted to objects (like in *List methods)?

Also, casting to object the first level only of $data does not address the "changes made in one listener will affect later listeners" in case of nested arrays too (I noticed that using a resource with embedded resources).

Could a recursive conversion of $data (using ArrayObject for lists and casting to object for hashmaps) address all use cases?

I'd like this solution if there're no side effects nor BCs.

PS: right now I've found the usage of ArrayObject in patchList but not in other methods.


Originally posted by @leogr at zfcampus/zf-rest#51 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant