You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
4.8KB

  1. <?php
  2. namespace Lc\SovBundle\Model\Ticket;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Lc\SovBundle\Doctrine\EntityInterface;
  8. use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait;
  9. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  10. use Lc\SovBundle\Model\User\UserInterface;
  11. #[ORM\MappedSuperclass]
  12. abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface
  13. {
  14. const TYPE_TECHNICAL_PROBLEM = 'technical-problem';
  15. const TYPE_GENERAL_QUESTION = 'general-question';
  16. const TICKET_STATUS_OPEN = 'open';
  17. const TICKET_STATUS_BEING_PROCESSED = 'being-processed';
  18. const TICKET_STATUS_PROCESSED = 'processed';
  19. const TICKET_STATUS_CLOSED = 'closed';
  20. #[ORM\Column(type: 'string', length: 32)]
  21. protected $type;
  22. #[ORM\Column(type: 'string', length: 32)]
  23. protected $status = self::TICKET_STATUS_OPEN;
  24. #[ORM\Column(type: 'string', length: 255)]
  25. protected $subject;
  26. #[ORM\Column(type: 'array', nullable: true)]
  27. protected $tags = [];
  28. #[ORM\Column(type: 'string', length: 64, nullable: true)]
  29. protected $visitorFirstname;
  30. #[ORM\Column(type: 'string', length: 64, nullable: true)]
  31. protected $visitorLastname;
  32. #[ORM\Column(type: 'string', length: 128, nullable: true)]
  33. protected $visitorEmail;
  34. #[ORM\Column(type: "string", length: 255, nullable: true)]
  35. protected $visitorToken;
  36. #[ORM\OneToMany(targetEntity: 'Lc\SovBundle\Model\Ticket\TicketMessageInterface', mappedBy: 'ticket', cascade: ['persist', 'remove'], orphanRemoval: true)]
  37. #[ORM\OrderBy(['id' => 'ASC'])]
  38. protected $ticketMessages;
  39. #[ORM\ManyToOne(targetEntity: 'Lc\SovBundle\Model\User\UserInterface', inversedBy: 'tickets')]
  40. protected $user;
  41. public function __construct()
  42. {
  43. $this->ticketMessages = new ArrayCollection();
  44. }
  45. public function getType(): ?string
  46. {
  47. return $this->type;
  48. }
  49. public function setType(string $type): self
  50. {
  51. $this->type = $type;
  52. return $this;
  53. }
  54. public function getStatus(): ?string
  55. {
  56. return $this->status;
  57. }
  58. public function setStatus(string $status): self
  59. {
  60. $this->status = $status;
  61. return $this;
  62. }
  63. public function getSubject(): ?string
  64. {
  65. return $this->subject;
  66. }
  67. public function setSubject(string $subject): self
  68. {
  69. $this->subject = $subject;
  70. return $this;
  71. }
  72. public function getTags(): ?array
  73. {
  74. return $this->tags;
  75. }
  76. public function setTags(?array $tags): self
  77. {
  78. $this->tags = $tags;
  79. return $this;
  80. }
  81. public function getVisitorFirstname(): ?string
  82. {
  83. return $this->visitorFirstname;
  84. }
  85. public function setVisitorFirstname(?string $visitorFirstname): self
  86. {
  87. $this->visitorFirstname = $visitorFirstname;
  88. return $this;
  89. }
  90. public function getVisitorLastname(): ?string
  91. {
  92. return $this->visitorLastname;
  93. }
  94. public function setVisitorLastname(?string $visitorLastname): self
  95. {
  96. $this->visitorLastname = $visitorLastname;
  97. return $this;
  98. }
  99. public function getVisitorEmail(): ?string
  100. {
  101. return $this->visitorEmail;
  102. }
  103. public function setVisitorEmail(?string $visitorEmail): self
  104. {
  105. $this->visitorEmail = $visitorEmail;
  106. return $this;
  107. }
  108. public function getVisitorToken(): ?string
  109. {
  110. return $this->visitorToken;
  111. }
  112. public function setVisitorToken(?string $visitorToken): self
  113. {
  114. $this->visitorToken = $visitorToken;
  115. return $this;
  116. }
  117. /**
  118. * @return Collection|TicketMessageInterface[]
  119. */
  120. public function getTicketMessages(): Collection
  121. {
  122. return $this->ticketMessages;
  123. }
  124. public function addTicketMessage(TicketMessageInterface $ticketMessage): self
  125. {
  126. if (!$this->ticketMessages->contains($ticketMessage)) {
  127. $this->ticketMessages[] = $ticketMessage;
  128. $ticketMessage->setTicket($this);
  129. }
  130. return $this;
  131. }
  132. public function removeTicketMessage(TicketMessageInterface $ticketMessage): self
  133. {
  134. if ($this->ticketMessages->contains($ticketMessage)) {
  135. $this->ticketMessages->removeElement($ticketMessage);
  136. // set the owning side to null (unless already changed)
  137. if ($ticketMessage->getTicket() === $this) {
  138. $ticketMessage->setTicket(null);
  139. }
  140. }
  141. return $this;
  142. }
  143. public function getUser(): ?UserInterface
  144. {
  145. return $this->user;
  146. }
  147. public function setUser(?UserInterface $user): self
  148. {
  149. $this->user = $user;
  150. return $this;
  151. }
  152. }