ReportMessage.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <?php
  2. namespace AppBundle\Entity\Message;
  3. use AppBundle\Entity\Organization\Organization;
  4. use AppBundle\Entity\Place\Place;
  5. use AppBundle\Entity\Place\Room;
  6. use AppBundle\Services\Messenger\Reporter\ReporterManager;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Dunglas\ApiBundle\Annotation\Iri;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13. * Logs des envois de messages (mails, sms, courriers)
  14. *
  15. * @Iri("http://schema.org/ReportMessage")
  16. */
  17. #[ORM\Entity]
  18. #[ORM\Table(name: 'ReportMessage')]
  19. #[ORM\Index(name: 'recipientType', columns: ['recipientType'])]
  20. #[ORM\Index(name: 'recipientId', columns: ['recipientId'])]
  21. class ReportMessage
  22. {
  23. /**
  24. * @var int
  25. */
  26. #[ORM\Column(type: 'integer')]
  27. #[ORM\Id]
  28. #[ORM\GeneratedValue(strategy: 'AUTO')]
  29. #[Groups(['reportmessage', 'messagesend_list'])]
  30. private $id;
  31. /**
  32. *
  33. * @var MessageInterface
  34. *
  35. */
  36. #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Message\Message', inversedBy: 'reportMessage')]
  37. #[Assert\NotNull]
  38. #[Groups(['reportmessage'])]
  39. private $message;
  40. /**
  41. * @var \DateTime
  42. */
  43. #[ORM\Column(type: 'datetime')]
  44. #[Assert\DateTime]
  45. #[Assert\NotNull]
  46. #[Groups(['reportmessage', 'report'])]
  47. private $dateSend;
  48. /**
  49. * @var string
  50. */
  51. #[ORM\Column(type: 'string')]
  52. #[Assert\NotNull]
  53. #[Groups(['reportmessage'])]
  54. private $recipientType;
  55. /**
  56. * @var int
  57. */
  58. #[ORM\Column(type: 'integer')]
  59. #[Assert\NotNull]
  60. #[Groups(['reportmessage'])]
  61. private $recipientId;
  62. /**
  63. * @var string
  64. */
  65. #[Groups(['report', 'messagesend_list_reportmessage'])]
  66. private $recipient;
  67. /**
  68. * @var ReporterManager
  69. */
  70. protected $reporterManager;
  71. /**
  72. * @var string
  73. */
  74. #[ORM\Column(type: 'string')]
  75. #[Assert\Type(type: 'string')]
  76. #[Assert\NotNull]
  77. #[Assert\Choice(callback: ['AppBundle\Enum\Message\ReportMessageSatusEnum', 'toArray'])]
  78. #[Groups(['reportmessage', 'report'])]
  79. private $status;
  80. /**
  81. * @var string
  82. */
  83. #[ORM\Column(type: 'string', nullable: true)]
  84. #[Assert\Type(type: 'string')]
  85. #[Groups(['reportmessage', 'report'])]
  86. private $smsId;
  87. public function __construct()
  88. {
  89. $this->dateSend = new \DateTime();
  90. }
  91. /**
  92. * Get id
  93. *
  94. * @return integer
  95. */
  96. public function getId()
  97. {
  98. return $this->id;
  99. }
  100. /**
  101. * Set dateSend
  102. *
  103. * @param \DateTime $dateSend
  104. *
  105. * @return ReportMessage
  106. */
  107. public function setDateSend($dateSend)
  108. {
  109. $this->dateSend = $dateSend;
  110. return $this;
  111. }
  112. /**
  113. * Get dateSend
  114. *
  115. * @return \DateTime
  116. */
  117. public function getDateSend()
  118. {
  119. return $this->dateSend;
  120. }
  121. /**
  122. * Set status
  123. *
  124. * @param string $status
  125. *
  126. * @return ReportMessage
  127. */
  128. public function setStatus($status)
  129. {
  130. $this->status = $status;
  131. return $this;
  132. }
  133. /**
  134. * Get status
  135. *
  136. * @return string
  137. */
  138. public function getStatus()
  139. {
  140. return $this->status;
  141. }
  142. /**
  143. * Set message
  144. *
  145. * @param \AppBundle\Entity\Message\Message $message
  146. *
  147. * @return ReportMessage
  148. */
  149. public function setMessage(\AppBundle\Entity\Message\Message $message)
  150. {
  151. $this->message = $message;
  152. return $this;
  153. }
  154. /**
  155. * Get message
  156. *
  157. * @return \AppBundle\Entity\Message\Message
  158. */
  159. public function getMessage()
  160. {
  161. return $this->message;
  162. }
  163. /**
  164. * Gets sms id
  165. *
  166. * @return string
  167. */
  168. public function getSmsId() {
  169. return $this->smsId;
  170. }
  171. /**
  172. * Sets sms id
  173. *
  174. * @param string $smsId
  175. * @return $this
  176. */
  177. public function setSmsId($smsId) {
  178. $this->smsId = $smsId;
  179. return $this;
  180. }
  181. /**
  182. * Set recipient
  183. *
  184. * @param string $recipientType
  185. *
  186. * @return ReportMessage
  187. */
  188. public function setRecipientType($recipientType)
  189. {
  190. $this->recipientType = $recipientType;
  191. return $this;
  192. }
  193. /**
  194. * Get recipient
  195. *
  196. * @return string
  197. */
  198. public function getRecipientType()
  199. {
  200. return $this->recipientType;
  201. }
  202. /**
  203. * Get the recipient id
  204. *
  205. * @return type
  206. */
  207. public function getRecipientId() {
  208. return $this->recipientId;
  209. }
  210. /**
  211. * Set the recipient id
  212. *
  213. * @param type $recipientId
  214. * @return $this
  215. */
  216. public function setRecipientId($recipientId) {
  217. $this->recipientId = $recipientId;
  218. return $this;
  219. }
  220. /**
  221. * {@inheritdoc}
  222. */
  223. public function getRecipient()
  224. {
  225. if (!$this->recipient) {
  226. if ($this->reporterManager) {
  227. return $this->reporterManager->loadRecipient($this);
  228. }
  229. }
  230. return null;
  231. }
  232. /**
  233. * {@inheritdoc}
  234. */
  235. public function setReportManagerr(ReporterManager $reporterManager)
  236. {
  237. $this->reporterManager = $reporterManager;
  238. }
  239. }