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

167 行
4.1KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Order;
  3. use Lc\CaracoleBundle\Doctrine\Extension\PriceTrait;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface;
  6. use Lc\CaracoleBundle\Model\Product\ProductInterface;
  7. use Lc\SovBundle\Doctrine\EntityInterface;
  8. /**
  9. * @ORM\MappedSuperclass()
  10. */
  11. abstract class OrderProductModel implements PriceInterface, EntityInterface
  12. {
  13. use PriceTrait;
  14. /**
  15. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="orderProducts", cascade={"persist"})
  16. * @ORM\JoinColumn(nullable=false)
  17. */
  18. protected $orderShop;
  19. /**
  20. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Product\ProductInterface"))
  21. */
  22. protected $product;
  23. /**
  24. * @ORM\Column(type="integer")
  25. */
  26. protected $quantityOrder;
  27. /**
  28. * @ORM\Column(type="float")
  29. */
  30. protected $quantityProduct;
  31. /**
  32. * @ORM\Column(type="string", length=255)
  33. */
  34. protected $title;
  35. /**
  36. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderProductReductionCatalogInterface", cascade={"persist", "remove"})
  37. */
  38. protected $orderProductReductionCatalog;
  39. /**
  40. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderProductRefundInterface", mappedBy="orderProduct", cascade={"persist", "remove"})
  41. */
  42. protected $orderProductRefund;
  43. public function __toString()
  44. {
  45. if ($this->getTitle()) {
  46. return $this->getTitle();
  47. } else {
  48. return $this->getProduct()->getProductFamily()->getTitle() . ' - ' . $this->getProduct()->getTitle();
  49. }
  50. }
  51. // isOrderProductAvailable
  52. /*public function isAvailable()
  53. {
  54. return $this->getProduct()->isAvailable($this->getQuantityOrder());
  55. }*/
  56. // isOrderProductAvailableAddCart
  57. // @TODO : à remettre en place si nécessaire
  58. /*public function isAvailableAddCart(OrderShopInterface $orderShop = null)
  59. {
  60. $product = $this->getProduct();
  61. return $this->isProductAvailable($product, $this->getQuantityOrder(), true, $orderShop);
  62. }*/
  63. public function getOrderShop(): ?OrderShopInterface
  64. {
  65. return $this->orderShop;
  66. }
  67. public function setOrderShop(?OrderShopInterface $orderShop): self
  68. {
  69. $this->orderShop = $orderShop;
  70. return $this;
  71. }
  72. public function getProduct(): ?ProductInterface
  73. {
  74. return $this->product;
  75. }
  76. public function setProduct(?ProductInterface $product): self
  77. {
  78. $this->product = $product;
  79. return $this;
  80. }
  81. public function getQuantityOrder(): ?int
  82. {
  83. return $this->quantityOrder;
  84. }
  85. public function setQuantityOrder(int $quantityOrder): self
  86. {
  87. $this->quantityOrder = $quantityOrder;
  88. return $this;
  89. }
  90. public function getQuantityProduct(): ?float
  91. {
  92. return $this->quantityProduct;
  93. }
  94. public function setQuantityProduct(float $quantityProduct): self
  95. {
  96. $this->quantityProduct = $quantityProduct;
  97. return $this;
  98. }
  99. public function getTitle(): ?string
  100. {
  101. return $this->title;
  102. }
  103. public function setTitle(string $title): self
  104. {
  105. $this->title = $title;
  106. return $this;
  107. }
  108. public function getOrderProductReductionCatalog(): ?OrderProductReductionCatalogInterface
  109. {
  110. return $this->orderProductReductionCatalog;
  111. }
  112. public function setOrderProductReductionCatalog(?OrderProductReductionCatalogInterface $orderProductReductionCatalog): self
  113. {
  114. $this->orderProductReductionCatalog = $orderProductReductionCatalog;
  115. return $this;
  116. }
  117. public function getOrderProductRefund(): ?OrderProductRefundInterface
  118. {
  119. return $this->orderProductRefund;
  120. }
  121. public function setOrderProductRefund(OrderProductRefundInterface $orderProductRefund): self
  122. {
  123. $this->orderProductRefund = $orderProductRefund;
  124. // set the owning side of the relation if necessary
  125. if ($orderProductRefund->getOrderProduct() !== $this) {
  126. $orderProductRefund->setOrderProduct($this);
  127. }
  128. return $this;
  129. }
  130. }