Type: New Feature
Resolution: Won't Fix
Affects Version/s: 1.1.5
Fix Version/s: None
Array Hydration, used for displaying especially, has great benefits (performance) but it has also a great drawback : impossible to use custom getters or methods on it.
But often, custom getters are really useful : think of a "vat" and a "ve_price" fields in the DB, and a getViPrice() custom getter to calculate VAT inc. price.
This a straightforward example, but you can also think of a value calculated from a parent of the record (e.g. ), of a statistic on its children (let's say Artist::getUnavailableAlbumsCount())
All those methods have something in common : they modify nothing, they are only highly useful helpers, but they cannot be present in hydrated Arrays.
In my case, I rarely use Array hydration, just because of that drawback. It's a major benefit of ORMs that disappears as soon as your hydrate Arrays !
Thus, my suggestion is: why not permit, while hydrating arrays, to add qualified custom accessors results to hydrated values ? It would be quite easy to implement, I think ?