|
- <?php
-
- namespace Lc\CaracoleBundle\Builder\Order;
-
- use Doctrine\ORM\EntityManagerInterface;
- use Lc\CaracoleBundle\Model\Order\OrderProductInterface;
- use Lc\CaracoleBundle\Repository\Order\OrderProductStore;
- use Lc\CaracoleBundle\Resolver\Price\PriceResolver;
- use Lc\CaracoleBundle\Solver\Price\PriceSolver;
-
- class OrderProductBuilder
- {
- protected EntityManagerInterface $entityManager;
- protected PriceSolver $priceSolver;
- protected OrderProductStore $orderProductStore;
-
- public function __construct(
- EntityManagerInterface $entityManager,
- PriceSolver $priceSolver,
- OrderProductStore $orderProductStore
- ) {
- $this->entityManager = $entityManager;
- $this->priceSolver = $priceSolver;
- $this->orderProductStore = $orderProductStore;
- }
-
- public function init(OrderProductInterface $orderProduct) :OrderProductInterface
- {
- $orderProduct->setTitle($orderProduct->getTitleOrderShop());
- $orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct()));
- $orderProduct->setBuyingPrice($this->priceSolver->getBuyingPrice($orderProduct->getProduct()));
- $orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited());
- $orderProduct->setTaxRate($orderProduct->getProduct()->getTaxRateInherited());
- $orderProduct->setQuantityProduct($orderProduct->getProduct()->getQuantityInherited());
-
- return $orderProduct;
- }
- }
|