UnionOfRAD/lithium — pull request #757 by coogle (2012-12-20 04:31:12+00:00)
Title: Modifying Collection and Entity so that you can pass in $options if you ...

...so desire. This allows you to for example pass in custom data handlers if desired for specific object handling when calling Entity->data()

This is useful because if you want to do something like allow DateTime objects to be used for 'date' fields, this can be done rather easily with a custom MongoDb Schema object and mostly works. Since Entities just push/pull data from arrays without caring what the data is this works as well.

The problem comes in when you try to do something like use validates(). At this point, the data is unceremoniously converted to an array using data() which crushes that DateTime object into an array with keys. Without this patch, you couldn't modify validates() to pass in a custom handler to address this issue (and thus keep the DateTime object in tact).

By no means is this a fix for what I think is a bigger issue that Entities don't allow you to manage your own custom types more effectively, but it does make sense to me that if the call-chain allows you to pass a handlers option in all the way up to data(), data() should as well. It's not an API everyone will use, but it certainly should be available to allow people to dictate exactly what they are getting back when they call data().