Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

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

Open
weierophinney opened this issue Sep 24, 2014 · 2 comments

Comments

@weierophinney
Copy link
Member

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).

TomHAnderson pushed a commit to TomHAnderson/zf-rest that referenced this issue Jan 20, 2015
…ion routines

- Altered `create()` to only inject the Location header if the entity
  has an identifier. If no identifier is present, it no longer raises a
  problem response.
@weierophinney weierophinney added this to the 1.1.0 milestone Jan 21, 2015
@leogr
Copy link

leogr commented Apr 3, 2015

👍

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.

@weierophinney
Copy link
Member Author

This repository has been closed and moved to laminas-api-tools/api-tools-rest; a new issue has been opened at laminas-api-tools/api-tools-rest#11.

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

No branches or pull requests

2 participants