-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
Description
It would be nice to be able to map an entire object with a callable/closure, as an alternative to creating a custom mapper. E.g. the following:
$config->registerMapping(SomeClass::class, SomeOther::class)
->useCustomMapper(new class extends CustomMapper {
public function mapToObject($source, $destination)
{
// do stuff
return $destination;
}
});Would become something like this:
$config->registerMapping(SomeClass::class, SomeOther::class)
->fromCallable(function ($source, $destination) {
// do stuff
return $destination;
}});Optionally the mapper can be passed as the third parameter. On a related note, the CustomMapper could maybe use a MapperAwareInterface as well.