選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

38 行
1.4KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Builder\Order;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
  5. use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
  6. use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
  7. class OrderProductBuilder
  8. {
  9. protected EntityManagerInterface $entityManager;
  10. protected PriceResolver $priceResolver;
  11. protected OrderProductStore $orderProductStore;
  12. public function __construct(
  13. EntityManagerInterface $entityManager,
  14. PriceResolver $priceResolver,
  15. OrderProductStore $orderProductStore
  16. ) {
  17. $this->entityManager = $entityManager;
  18. $this->priceResolver = $priceResolver;
  19. $this->orderProductStore = $orderProductStore;
  20. }
  21. public function init(OrderProductInterface $orderProduct)
  22. {
  23. $orderProduct->setTitle($orderProduct->getTitleOrderShop());
  24. $orderProduct->setPrice($this->priceResolver->getPrice($orderProduct->getProduct()));
  25. $orderProduct->setBuyingPrice($this->priceResolver->getBuyingPrice($orderProduct->getProduct()));
  26. $orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited());
  27. $orderProduct->setTaxRate($orderProduct->getProduct()->getTaxRateInherited());
  28. $orderProduct->setQuantityProduct($orderProduct->getProduct()->getQuantityInherited());
  29. return $orderProduct;
  30. }
  31. }