zf-fr/zfr-rest — pull request #136 by bakura10 (2014-03-09 10:24:04+00:00)
Title: Remove hydrator mapping for Collection

ping @danizord

This PR removes the Hydrator mapping in the @REST\Collection mapping. The reason is that it was confusing as hell. My idea with this feature was to provide a clean way to allow to serialize an entity differently if we hit /users or /users/1 (for instance to provide more details when fetching a specific entity). However, I now think this is a bad idea (especially if you have pagination, there is few reason to shrink the response).

But the biggest problem is that, as of today, the collection hydrator was only used in the renderer. For instance, when hitting POST /users, you actually reach the mapping defined in the collection part, BUT you are actually creating a SINGLE user inside a context of a COLLECTION. So the Post handler was using... the hydrator defined in the "Resource" annotation. So this was a bit counter-intuitive and found it very confusing to use and can lead to very strange results.

So, as I did for input filter, for now I prefer to remove the hydrator from collection mapping, and only keep the "controller" value. This is much cleaner, and does not force you to add a hydrator annotation each time (99% of the time it's the same as in the Resource annotation).

We can always add this feature later, but as it is implemented today, it's wrong.