Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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