Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

OrderStatus.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 $statusAliasWaitingDelivery = [
  35. self::ALIAS_WAITING_DELIVERY,
  36. self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
  37. ];
  38. static $statusAliasAsCart = [
  39. self::ALIAS_CART,
  40. self::ALIAS_WAITING_PAYMENT_ONLINE,
  41. self::ALIAS_WAITING_PAYMENT_CREDIT,
  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. }