Backport Doctrine conversions from 2.0 @tfotis