Skip to content

Programmatically assign transformers to properties #250

@jorr-it

Description

@jorr-it

Is it possible to programmatically configure custom transformations (like in callbacks) for specific properties or can this only be in attributes?

For example, with .NET's AutoMapper:

var configuration = new MapperConfiguration(cfg =>
  cfg.CreateMap<Source, Destination>()
	.ForMember(dest => dest.SomeValuefff)
);

or in a competing PHP AutoMapper:

$config = new AutoMapperConfig();
$config
    ->registerMapping(Employee::class, EmployeeDto::class)
    ->forMember('age', function (Employee $source) {
        return date('Y') - $source->getBirthYear();
    });

I didn't find anything about this in your documentation. It could be useful when we want to dynamically define the mappings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pr welcomeFeature is accepted, it needs an implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions