Description
Hey guys. I can't find a way how to map flat properties of my source DTO into my entity class which contains Embeddable properties.
I don't want to implement a custom ObjectMapperMetadataFactoryInterface to add a custom mapping strategy, as this will over-complicate things in our code. Any idea if this is possible or is this a new feature?
Example:
// My source DTO
readonly class UserDto
{
public function __construct(
#[Map(target: 'address.zipcode')] public bool $userAddressZipcode,
#[Map(target: 'address.city')] public bool $userAddressCity
) {
}
}
// Target User entity
class User
{
#[ORM\Embedded(Address::class)]
private Address $address
}
// Some controller
public function doStuff(UserDto $dto)
{
$this->objectMapper->map(source: $dto, target: User::class);
}