141 rinda
3.9KB

  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_PAYMENT_CREDIT = 'waiting-payment-credit' ;
  15. const ALIAS_PAID_ONLINE = 'paid-online' ;
  16. const ALIAS_ERROR_PAYMENT_ONLINE = 'error-payment-online' ;
  17. const ALIAS_PAID_BY_CREDIT = 'paid-by-credit' ;
  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_ONLINE,
  28. self::ALIAS_PAID_BY_CREDIT,
  29. self::ALIAS_WAITING_DELIVERY,
  30. self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
  31. self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
  32. self::ALIAS_DONE
  33. ] ;
  34. static $statusAliasAsCart = [
  35. self::ALIAS_CART,
  36. self::ALIAS_WAITING_PAYMENT_ONLINE,
  37. self::ALIAS_WAITING_PAYMENT_CREDIT,
  38. self::ALIAS_ERROR_PAYMENT_ONLINE
  39. ];
  40. /**
  41. * @ORM\Column(type="string", length=255)
  42. */
  43. protected $title;
  44. /**
  45. * @ORM\Column(type="text", nullable=true)
  46. */
  47. protected $description;
  48. /**
  49. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
  50. */
  51. protected $nextStatusAllowed;
  52. /**
  53. * @ORM\Column(type="string", length=255)
  54. */
  55. protected $alias;
  56. public function __toString()
  57. {
  58. return $this->title. ' ['.$this->alias.']';
  59. }
  60. public function __construct()
  61. {
  62. $this->nextStatusAllowed = new ArrayCollection();
  63. }
  64. public function getTitle(): ?string
  65. {
  66. return $this->title;
  67. }
  68. public function setTitle(string $title): self
  69. {
  70. $this->title = $title;
  71. return $this;
  72. }
  73. public function getDescription(): ?string
  74. {
  75. return $this->description;
  76. }
  77. public function setDescription(?string $description): self
  78. {
  79. $this->description = $description;
  80. return $this;
  81. }
  82. /**
  83. * @return Collection|self[]
  84. */
  85. public function getNextStatusAllowed(): Collection
  86. {
  87. return $this->nextStatusAllowed;
  88. }
  89. public function addNextStatusAllowed(self $nextStatusAllowed): self
  90. {
  91. if (!$this->nextStatusAllowed->contains($nextStatusAllowed)) {
  92. $this->nextStatusAllowed[] = $nextStatusAllowed;
  93. }
  94. return $this;
  95. }
  96. public function removeNextStatusAllowed(self $nextStatusAllowed): self
  97. {
  98. if ($this->nextStatusAllowed->contains($nextStatusAllowed)) {
  99. $this->nextStatusAllowed->removeElement($nextStatusAllowed);
  100. }
  101. return $this;
  102. }
  103. public function getAlias(): ?string
  104. {
  105. return $this->alias;
  106. }
  107. public function setAlias(string $alias): self
  108. {
  109. $this->alias = $alias;
  110. return $this;
  111. }
  112. }