src/Entity/PointTransactionType.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PointTransactionTypeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. /**
  12. * @ORM\Entity(repositoryClass=PointTransactionTypeRepository::class)
  13. *
  14. * @Serializer\ExclusionPolicy("ALL")
  15. */
  16. class PointTransactionType
  17. {
  18. public const ORDER = 'order';
  19. public const FIDELITY = 'fidelity';
  20. public const SPONSORSHIP = 'sponsorship';
  21. public const EXCEPTIONAL = 'exceptional';
  22. public const PAYMENT = 'payment';
  23. public const ORDER_CREDIT = 'order_credit';
  24. public const VIRTUAL = 'virtual';
  25. public const PURCHASE_KO = 'purchase_ko';
  26. public const EXPIRATION = 'expiration';
  27. /**
  28. * @ORM\Id
  29. * @ORM\GeneratedValue
  30. * @ORM\Column(type="integer")
  31. *
  32. * @Expose
  33. * @Groups ({"point_transaction_type"})
  34. */
  35. private ?int $id = NULL;
  36. /**
  37. * Slug
  38. *
  39. * @ORM\Column(type="string", length=15, unique=true)
  40. *
  41. * @Assert\NotBlank
  42. *
  43. * @Expose
  44. * @Groups ({"point_transaction_type"})
  45. */
  46. private ?string $slug = NULL;
  47. /**
  48. * Nom
  49. *
  50. * @ORM\Column(type="string", length=255)
  51. *
  52. * @Assert\NotBlank
  53. *
  54. * @Expose
  55. * @Groups ({"point_transaction_type"})
  56. */
  57. private ?string $name = NULL;
  58. /**
  59. * Description
  60. *
  61. * @ORM\Column(type="string", length=255, nullable=true)
  62. *
  63. * @Expose
  64. * @Groups ({"point_transaction_type"})
  65. */
  66. private ?string $description = NULL;
  67. /**
  68. * Par défaut
  69. *
  70. * @ORM\Column(type="boolean", options={"default": false})
  71. *
  72. * @Expose
  73. * @Groups ({"point_transaction_type"})
  74. */
  75. private bool $isDefault = FALSE;
  76. /**
  77. * Pour les challenges
  78. *
  79. * @ORM\Column(type="boolean", options={"default": false})
  80. *
  81. * @Expose
  82. * @Groups({"point_transaction_type"})
  83. */
  84. private bool $challenge = FALSE;
  85. /**
  86. * Liste des transactions rattachées
  87. *
  88. * @ORM\OneToMany(targetEntity=PointTransaction::class, mappedBy="transactionType")
  89. */
  90. private Collection $pointTransactions;
  91. public function __construct()
  92. {
  93. $this->pointTransactions = new ArrayCollection();
  94. }
  95. public function getId(): ?int
  96. {
  97. return $this->id;
  98. }
  99. public function getSlug(): ?string
  100. {
  101. return $this->slug;
  102. }
  103. public function setSlug(string $slug): self
  104. {
  105. $this->slug = $slug;
  106. return $this;
  107. }
  108. public function getName(): ?string
  109. {
  110. return $this->name;
  111. }
  112. public function setName(string $name): self
  113. {
  114. $this->name = $name;
  115. return $this;
  116. }
  117. public function getDescription(): ?string
  118. {
  119. return $this->description;
  120. }
  121. public function setDescription(?string $description): self
  122. {
  123. $this->description = $description;
  124. return $this;
  125. }
  126. public function getIsDefault(): bool
  127. {
  128. return $this->isDefault;
  129. }
  130. public function setIsDefault(bool $isDefault): self
  131. {
  132. $this->isDefault = $isDefault;
  133. return $this;
  134. }
  135. public function getChallenge(): bool
  136. {
  137. return $this->challenge;
  138. }
  139. public function setChallenge(bool $challenge): self
  140. {
  141. $this->challenge = $challenge;
  142. return $this;
  143. }
  144. /**
  145. * @return Collection|PointTransaction[]
  146. */
  147. public function getPointTransactions(): Collection
  148. {
  149. return $this->pointTransactions;
  150. }
  151. public function addPointTransaction(PointTransaction $pointTransaction): self
  152. {
  153. if (!$this->pointTransactions->contains($pointTransaction)) {
  154. $this->pointTransactions[] = $pointTransaction;
  155. $pointTransaction->setTransactionType($this);
  156. }
  157. return $this;
  158. }
  159. public function removePointTransaction(PointTransaction $pointTransaction): self
  160. {
  161. if ($this->pointTransactions->removeElement($pointTransaction)) {
  162. // set the owning side to null (unless already changed)
  163. if ($pointTransaction->getTransactionType() === $this) {
  164. $pointTransaction->setTransactionType(NULL);
  165. }
  166. }
  167. return $this;
  168. }
  169. }