Hey,
The objective is to make AutoMapper easier to work with for developpers.
In this issue I'll try to list all stuff developpers needs to fit their needs when using AutoMapper.
All the following stuff are examples and subject to change in their implementation.
class Foo
{
public function __construct(
#[MapTo(('array', 'phrase')]
#[MapTo(Bar::class, 'phrase')]
public string $sentence,
) {
}
}
class Foo
{
public function __construct(
#[MapFrom(('array', 'phrase')]
#[MapFrom(Bar::class, 'phrase')]
public string $sentence,
) {
}
}
class Foo
{
public function __construct(
#[MapIf(('array', fn() => true)]
#[MapIf(Bar::class, fn() => false)]
public string $sentence,
) {
}
}
final readonly class FromSourceCustomPropertyTransformer implements CustomPropertyTransformerInterface
{
public function supports(string $source, string $target, string $propertyName): bool
{
return $source === UserDTO::class && $target === 'array' && $propertyName === 'name';
}
public function transform(mixed $input): mixed
{
return "{$input} set by custom property transformer";
}
}
final readonly class FromTargetCustomModelTransformer implements CustomModelTransformerInterface
{
public function supports(string $source, string $target): bool
{
return $source === 'array' && $target === AddressDTO::class;
}
public function transform(mixed $input): mixed
{
$addressDTO = new \AutoMapper\Tests\Fixtures\AddressDTO();
$addressDTO->city = "{$input['city']} from custom model transformer";
return $addressDTO;
}
}
class Foo
{
public function __construct(
public string $sentence,
) {
}
#[MapEvent(Event::AFTER_INITIALIZATION)]
public function doctrineHook(mixed $object): void
{
// link my entity to Doctrine UOW
}
}
Hey,
The objective is to make AutoMapper easier to work with for developpers.
In this issue I'll try to list all stuff developpers needs to fit their needs when using AutoMapper.
All the following stuff are examples and subject to change in their implementation.
beforeInitializationafterInitializationafterHydratation