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.

TicketModel.php 5.8KB

3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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\Pattern\AbstractLightEntity;
  9. use Lc\SovBundle\Model\User\UserInterface;
  10. /**
  11. * @ORM\MappedSuperclass()
  12. */
  13. abstract class TicketModel extends AbstractLightEntity implements TicketInterface, EntityInterface
  14. {
  15. const TYPE_TECHNICAL_PROBLEM = 'technical-problem';
  16. const TYPE_GENERAL_QUESTION = 'general-question';
  17. const TICKET_STATUS_OPEN = 'open';
  18. const TICKET_STATUS_BEING_PROCESSED = 'being-processed';
  19. const TICKET_STATUS_CLOSED = 'closed';
  20. /**
  21. * @Gedmo\Blameable(on="create")
  22. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  23. * @ORM\JoinColumn(nullable=true)
  24. */
  25. protected $createdBy;
  26. /**
  27. * @Gedmo\Blameable(on="update")
  28. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  29. * @ORM\JoinColumn(nullable=true)
  30. */
  31. protected $updatedBy;
  32. /**
  33. * @ORM\Column(type="string", length=32)
  34. */
  35. protected $type;
  36. /**
  37. * @ORM\Column(type="string", length=32)
  38. */
  39. protected $status;
  40. /**
  41. * @ORM\Column(type="string", length=255)
  42. */
  43. protected $subject;
  44. /**
  45. * @ORM\Column(type="array", nullable=true)
  46. */
  47. protected $tags = [];
  48. /**
  49. * @ORM\Column(type="string", length=64, nullable=true)
  50. */
  51. protected $visitorFirstname;
  52. /**
  53. * @ORM\Column(type="string", length=64, nullable=true)
  54. */
  55. protected $visitorLastname;
  56. /**
  57. * @ORM\Column(type="string", length=128, nullable=true)
  58. */
  59. protected $visitorEmail;
  60. /**
  61. * @ORM\Column(type="string", length=255, nullable=true)
  62. */
  63. protected $visitorToken;
  64. /**
  65. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketMessageInterface", mappedBy="ticket", orphanRemoval=true)
  66. * @ORM\OrderBy({"id" = "ASC"})
  67. */
  68. protected $ticketMessages;
  69. /**
  70. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="tickets")
  71. */
  72. protected $user;
  73. public function __construct()
  74. {
  75. $this->ticketMessages = new ArrayCollection();
  76. }
  77. public function getUsername()
  78. {
  79. if ($this->getUser()) {
  80. return $this->getUser()->getName();
  81. } else {
  82. return strtoupper($this->getVisitorLastname()) . ' ' . $this->getVisitorFirstname();
  83. }
  84. }
  85. public function getVisitorInfos()
  86. {
  87. return strtoupper($this->getVisitorLastname()) . ' ' . $this->getVisitorFirstname(
  88. ) . ' (' . $this->getVisitorEmail() . ')';
  89. }
  90. public function getType(): ?string
  91. {
  92. return $this->type;
  93. }
  94. public function setType(string $type): self
  95. {
  96. $this->type = $type;
  97. return $this;
  98. }
  99. public function getTypeLabel(): string
  100. {
  101. return 'field.Ticket.typeOptions.' . $this->getType();
  102. }
  103. public function getStatus(): ?string
  104. {
  105. return $this->status;
  106. }
  107. public function setStatus(string $status): self
  108. {
  109. $this->status = $status;
  110. return $this;
  111. }
  112. public function getStatusLabel(): string
  113. {
  114. return 'field.Ticket.statusOptions.' . $this->getStatus();
  115. }
  116. public function getSubject(): ?string
  117. {
  118. return $this->subject;
  119. }
  120. public function setSubject(string $subject): self
  121. {
  122. $this->subject = $subject;
  123. return $this;
  124. }
  125. public function getTags(): ?array
  126. {
  127. return $this->tags;
  128. }
  129. public function setTags(?array $tags): self
  130. {
  131. $this->tags = $tags;
  132. return $this;
  133. }
  134. public function getVisitorFirstname(): ?string
  135. {
  136. return $this->visitorFirstname;
  137. }
  138. public function setVisitorFirstname(?string $visitorFirstname): self
  139. {
  140. $this->visitorFirstname = $visitorFirstname;
  141. return $this;
  142. }
  143. public function getVisitorLastname(): ?string
  144. {
  145. return $this->visitorLastname;
  146. }
  147. public function setVisitorLastname(?string $visitorLastname): self
  148. {
  149. $this->visitorLastname = $visitorLastname;
  150. return $this;
  151. }
  152. public function getVisitorEmail(): ?string
  153. {
  154. return $this->visitorEmail;
  155. }
  156. public function setVisitorEmail(?string $visitorEmail): self
  157. {
  158. $this->visitorEmail = $visitorEmail;
  159. return $this;
  160. }
  161. public function getVisitorToken(): ?string
  162. {
  163. return $this->visitorToken;
  164. }
  165. public function setVisitorToken(?string $visitorToken): self
  166. {
  167. $this->visitorToken = $visitorToken;
  168. return $this;
  169. }
  170. /**
  171. * @return Collection|TicketMessageInterface[]
  172. */
  173. public function getTicketMessages(): Collection
  174. {
  175. return $this->ticketMessages;
  176. }
  177. public function addTicketMessage(TicketMessageInterface $ticketMessage): self
  178. {
  179. if (!$this->ticketMessages->contains($ticketMessage)) {
  180. $this->ticketMessages[] = $ticketMessage;
  181. $ticketMessage->setTicket($this);
  182. }
  183. return $this;
  184. }
  185. public function removeTicketMessage(TicketMessageInterface $ticketMessage): self
  186. {
  187. if ($this->ticketMessages->contains($ticketMessage)) {
  188. $this->ticketMessages->removeElement($ticketMessage);
  189. // set the owning side to null (unless already changed)
  190. if ($ticketMessage->getTicket() === $this) {
  191. $ticketMessage->setTicket(null);
  192. }
  193. }
  194. return $this;
  195. }
  196. public function getUser(): ?UserInterface
  197. {
  198. return $this->user;
  199. }
  200. public function setUser(?UserInterface $user): self
  201. {
  202. $this->user = $user;
  203. return $this;
  204. }
  205. }