Slide 52
Slide 52 text
@xabbuh && @el_stoffel
$self->category = $product->getCategory();
$self->priceAmount = $product->getPrice()->getAmount();
$self->priceTax = $product->getPrice()->getTax();
$self->priceCurrency = $product->getPrice()->getCurrency();
return $self;
}
public function toEntity(ProductEntity $product = null): ProductEntity
{
$price = new Price((int) $this->priceAmount, $this->priceTax, $this->priceCurrency);
if (null === $product) {
return new ProductEntity($this->name, $this->category, $price);
}
if ($product->getName() !== $this->name) {
$product->rename($this->name);
}
if ($product->getCategory() !== $this->category) {
$product->moveToCategory($this->category);
}
if (!$price->equals($product->getPrice())) {
$product->costs($price);
}
return $product;
}
}
DTO src/Form/DTO/Product.php
@xabbuh && @el_stoffel