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

146 lines
4.0KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. /**
  7. * @ORM\MappedSuperclass()
  8. */
  9. abstract class OrderStatus
  10. {
  11. const ALIAS_CART = 'cart' ;
  12. const ALIAS_CART_CANCELED = 'cart-canceled' ;
  13. const ALIAS_WAITING_PAYMENT_ONLINE = 'waiting-payment-online' ;
  14. const ALIAS_WAITING_BANK_RETURN = 'waiting-bank-return' ;
  15. const ALIAS_PARTIAL_PAYMENT = 'partial-payment' ;
  16. const ALIAS_PAID = 'paid' ;
  17. const ALIAS_ERROR_PAYMENT_ONLINE = 'error-payment-online' ;
  18. const ALIAS_WAITING_DELIVERY = 'waiting-delivery' ;
  19. const ALIAS_WAITING_DELIVERY_WITH_PAYMENT = 'waiting-delivery-with-payment' ;
  20. const ALIAS_DELIVERED_WITHOUT_PAYMENT = 'delivered-without-payment' ;
  21. const ALIAS_DONE = 'done' ;
  22. const ALIAS_CANCELED = 'canceled' ;
  23. const ALIAS_CANCELED_WAITING_REFUND = 'canceled-waiting-refund' ;
  24. const ALIAS_REFUND = 'refund' ;
  25. //TODO : AJOUTER un champ valid ds orderSTATUS
  26. static $statusAliasAsValid = [
  27. self::ALIAS_PAID,
  28. self::ALIAS_WAITING_DELIVERY,
  29. self::ALIAS_WAITING_BANK_RETURN,
  30. self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
  31. self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
  32. self::ALIAS_DONE
  33. ] ;
  34. static $statusAliasWaitingDelivery = [
  35. self::ALIAS_WAITING_DELIVERY,
  36. self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
  37. ];
  38. static $statusAliasAsCart = [
  39. self::ALIAS_CART,
  40. self::ALIAS_PARTIAL_PAYMENT,
  41. self::ALIAS_WAITING_PAYMENT_ONLINE,
  42. self::ALIAS_ERROR_PAYMENT_ONLINE
  43. ];
  44. /**
  45. * @ORM\Column(type="string", length=255)
  46. */
  47. protected $title;
  48. /**
  49. * @ORM\Column(type="text", nullable=true)
  50. */
  51. protected $description;
  52. /**
  53. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
  54. */
  55. protected $nextStatusAllowed;
  56. /**
  57. * @ORM\Column(type="string", length=255)
  58. */
  59. protected $alias;
  60. public function __toString()
  61. {
  62. return $this->title. ' ['.$this->alias.']';
  63. }
  64. public function __construct()
  65. {
  66. $this->nextStatusAllowed = new ArrayCollection();
  67. }
  68. public function getTitle(): ?string
  69. {
  70. return $this->title;
  71. }
  72. public function setTitle(string $title): self
  73. {
  74. $this->title = $title;
  75. return $this;
  76. }
  77. public function getDescription(): ?string
  78. {
  79. return $this->description;
  80. }
  81. public function setDescription(?string $description): self
  82. {
  83. $this->description = $description;
  84. return $this;
  85. }
  86. /**
  87. * @return Collection|self[]
  88. */
  89. public function getNextStatusAllowed(): Collection
  90. {
  91. return $this->nextStatusAllowed;
  92. }
  93. public function addNextStatusAllowed(self $nextStatusAllowed): self
  94. {
  95. if (!$this->nextStatusAllowed->contains($nextStatusAllowed)) {
  96. $this->nextStatusAllowed[] = $nextStatusAllowed;
  97. }
  98. return $this;
  99. }
  100. public function removeNextStatusAllowed(self $nextStatusAllowed): self
  101. {
  102. if ($this->nextStatusAllowed->contains($nextStatusAllowed)) {
  103. $this->nextStatusAllowed->removeElement($nextStatusAllowed);
  104. }
  105. return $this;
  106. }
  107. public function getAlias(): ?string
  108. {
  109. return $this->alias;
  110. }
  111. public function setAlias(string $alias): self
  112. {
  113. $this->alias = $alias;
  114. return $this;
  115. }
  116. }