Casting Typed Properties in Aggregate using Doctrine

We’re creating a setup that uses DDD, and we persist our Aggregates with Doctrine. The entity consists out of multiple class properties which are (almost all) non-primitive types (i.e. CustomerFirstName, CustomerLastName).

For those properties, we’re using an embeddable to define the actual column in the persistence.

An example is;

/**
 * @ORMColumn(type="orderCustomerLastNameType")
 * @ORMEmbedded(class="ACMEDomainValueObjectsOrderCustomerLastName", columnPrefix=false)
 */
private OrderCustomerLastName $lastName; 

Now to reconstruct the Aggregate from the Database we use a custom column type.

The problem is that we would need a type for every ValueObject we’re using, which is inconvenient (to say at least).

We’re looking to create a generic type converter for all ValueObjects but for that we would need to know the class instance of the to be converted object.

The current Hydrator is only passing the value and the platform to the type converter.

Any suggestions, tips or workarounds on how to solve this is greatly appreciated!