You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've come across a possible imitation. I have a DTO extending another that has a property mapper. What I assumed would happen is for the parent's mapper to run, but that doesn't seem to be the case. I would like the mapper for the parent to run, otherwise we'll have to duplicate the mapper.
Example:
class ProductWithFeaturedDto extends ProductDto
{
public ?bool $featured = false;
}
#[AsPropertyMapper(targetClass: ProductDto::class)]
class ProductDtoMapper
{
#[AsPropertyMapper]
public function mapBaseCost(Product $product): ?float
{
$price = $product->getPrices()->first();
if ($price) {
return round($price->getPriceRrp(), 2);
}
return null;
}
}
Both DTOs are getting mapped from the same source, if that helps.
We've tried using it like, but attribute is not repeatable.
#[AsPropertyMapper(targetClass: ProductDto::class)]
#[AsPropertyMapper(targetClass: ProductWithFeaturedDto::class)]
class ProductDtoMapper
Could you let me know if this is something that can be achieved?
The text was updated successfully, but these errors were encountered:
Hey,
I've come across a possible imitation. I have a DTO extending another that has a property mapper. What I assumed would happen is for the parent's mapper to run, but that doesn't seem to be the case. I would like the mapper for the parent to run, otherwise we'll have to duplicate the mapper.
Example:
Both DTOs are getting mapped from the same source, if that helps.
We've tried using it like, but attribute is not repeatable.
Could you let me know if this is something that can be achieved?
The text was updated successfully, but these errors were encountered: