Skip to content
Advertisement

Aliasing fields using partial object syntax + array hydrator in doctrine 2

Is there any way to alias fields when using partial object syntax in Doctrine 2?

I know I can do this:

JavaScript

However I need to use the partial object syntax in order for doctrine to retrieve the result in a nested relational heirarchy:

JavaScript

I dug around in DoctrineORMInternalHydrationArrayHydrator but didn’t see any hooks or anything, and it doesn’t look like Doctrine has a postSelect event or something that would allow me to implement my own mutation.

Thanks for any help!

Advertisement

Answer

Not very efficient, but I ended up subclassing the ArrayHydrator and mutating the keys myself.

Hopefully there is a better way, if not I hope this helps someone

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement