Jira issue originally created by user marijn:
I was wondering if it would be possible to create custom hydrators for Doctrine 2.0. If I have a look at the EntityManager#getHydrator() method it seems not. Or should I subclass the EntityManager and override the getHydrator() method?
Comment created by @guilhermeblanco:
Maybe we should just take the approach we did for registering types and reuse same idea in hydrators too.
Of course it'll require us to write an Interface so people can at least have an idea of what's needed and make the AbstractHydrator to implement it.
I'm +1 to include this support, since we already have it in earlier 1.X and people can surely uses it if they're not affordable with our nice hydrators.
Comment created by @jwage:
I'd like to see this in 2.0 as well too.
Comment created by romanb:
Scheduled for the first beta. I already have an idea on how to do this. Should be fairly easy.
Jon, would you want to give this a try? Custom hydrators should be registered as closures I think, since they are instantiated on demand.
Just another thought on the issue. Maybe it is enough to set the hydrator on a Query to use. That way we don't need additional configuration cruft.
So instead of being able to register custom "hydration modes", you can simply set a custom "hydrator" on a specific query.
Comment created by marijn:
I agree with Roman. As an added bonus: that's what people are used to from Doctrine 1
How do you want to handle that roman? Another setting to set the custom query? or just allow a default hydrator that expects a string className in the EntityManager#newHydrator() method? or what were you thinking?
Issue was closed with resolution "Fixed"