You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
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. }