Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

OrderProductBuilder.php 2.1KB

3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. use Lc\CaracoleBundle\Solver\Order\OrderProductSolver;
  8. use Lc\CaracoleBundle\Solver\Price\PriceSolver;
  9. use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;
  10. use Lc\CaracoleBundle\Solver\Product\ProductSolver;
  11. class OrderProductBuilder
  12. {
  13. protected EntityManagerInterface $entityManager;
  14. protected PriceSolver $priceSolver;
  15. protected OrderProductStore $orderProductStore;
  16. protected ProductSolver $productSolver;
  17. protected ProductFamilySolver $productFamilySolver;
  18. protected OrderProductSolver $orderProductSolver;
  19. public function __construct(
  20. EntityManagerInterface $entityManager,
  21. PriceSolver $priceSolver,
  22. OrderProductStore $orderProductStore,
  23. ProductSolver $productSolver,
  24. OrderProductSolver $orderProductSolver,
  25. ProductFamilySolver $productFamilySolver
  26. ) {
  27. $this->entityManager = $entityManager;
  28. $this->priceSolver = $priceSolver;
  29. $this->orderProductStore = $orderProductStore;
  30. $this->productSolver = $productSolver;
  31. $this->orderProductSolver = $orderProductSolver;
  32. $this->productFamilySolver = $productFamilySolver;
  33. }
  34. public function init(OrderProductInterface $orderProduct) :OrderProductInterface
  35. {
  36. $orderProduct->setTitle($this->orderProductSolver->getTitleOrderShop($orderProduct));
  37. $orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct()));
  38. $orderProduct->setBuyingPrice($this->priceSolver->getBuyingPrice($orderProduct->getProduct()));
  39. $orderProduct->setUnit($this->productSolver->getUnitInherited($orderProduct->getProduct()));
  40. $orderProduct->setTaxRate($this->productFamilySolver->getTaxRateInherited($orderProduct->getProduct()));
  41. $orderProduct->setQuantityProduct($this->productSolver->getQuantityInherited($orderProduct->getProduct()));
  42. return $orderProduct;
  43. }
  44. }