|
- <?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;
-
- class OrderProductBuilder
- {
- protected EntityManagerInterface $entityManager;
- protected PriceResolver $priceResolver;
- protected OrderProductStore $orderProductStore;
-
- public function __construct(
- EntityManagerInterface $entityManager,
- PriceResolver $priceResolver,
- OrderProductStore $orderProductStore
- ) {
- $this->entityManager = $entityManager;
- $this->priceResolver = $priceResolver;
- $this->orderProductStore = $orderProductStore;
- }
-
- public function init(OrderProductInterface $orderProduct)
- {
- $orderProduct->setTitle($orderProduct->getTitleOrderShop());
- $orderProduct->setPrice($this->priceResolver->getPrice($orderProduct->getProduct()));
- $orderProduct->setBuyingPrice($this->priceResolver->getBuyingPrice($orderProduct->getProduct()));
- $orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited());
- $orderProduct->setTaxRate($orderProduct->getProduct()->getTaxRateInherited());
- $orderProduct->setQuantityProduct($orderProduct->getProduct()->getQuantityInherited());
-
- return $orderProduct;
- }
- }
|