Closed jeremyVignelles closed 5 months ago
Hey @jeremyVignelles and thanks for your issue.
For your case I would have used a transformer
as following:
#[MapFrom(source: ARequest::class, transformer: "'A'")]
#[MapFrom(source: BRequest::class, tranformer: "'B'")]
public string $type;
Please note that I used both "
and '
because you need to put the ExpressionLanguage parsed content in a string and you need tell ExpressionLanguage that you want to return a string (thanks to '
in my example).
Does that fit your use-case ?
Sounds good, thanks for your quick reply.
I didn't test this as our code base is not ready yet, so I'm going to close this issue and reopen later if more help is needed.
I have a use case that can be summarized like this:
Both ARequest and BRequest can be mapped to my Entity, but I want $type to be either 'A' or 'B'.
Is there a way to automatically fill $type ?
Something like: