Closed ivoba closed 4 years ago
Hi @ivoba. I might be understanding your use case wrong, but I think mapTo
does what you want. Your config could look like this:
$config->registerMapping(DataType::ARRAY, Thing::class);
$config->registerMapping(DataType::ARRAY, MyObject::class)
->forMember('things', Operation::mapTo(Thing::class));
This works because mapTo
supports both single and multiple values. Please let me know if this solved your problem!
@mark-gerarts yes you are right, this works as you describe. Probably i had some wrong input data. Thank you!
Is it possible to map to a typed list resp. an array of objects?
Imagine a class like this:
When mapping from an array i did this:
I guess it would be convenient to have a operation for this custom callback to map to a list. Like:
Operation::mapArrayToArray(Things::class);