Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

224 lines
4.9KB

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