src/Entity/ExpertAgency.php line 24

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use DH\Auditor\Provider\Doctrine\Auditing\Annotation as Audit;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. /**
  7. * ExpertAgency
  8. *
  9. * @ORM\Table(name="expert_agency", uniqueConstraints={@ORM\UniqueConstraint(name="reference_idx", columns={"contact_email", "deletedAt"})})
  10. *
  11. * @ORM\Entity
  12. *
  13. * @ORM\HasLifecycleCallbacks
  14. *
  15. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  16. *
  17. * @Audit\Auditable
  18. *
  19. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  20. */
  21. class ExpertAgency
  22. {
  23. /**
  24. * @var int
  25. *
  26. * @ORM\Column(name="id", type="integer")
  27. *
  28. * @ORM\Id
  29. *
  30. * @ORM\GeneratedValue(strategy="IDENTITY")
  31. */
  32. private $id;
  33. /**
  34. * @var \DateTime|null
  35. *
  36. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  37. */
  38. private $deletedAt;
  39. /**
  40. * @var string
  41. *
  42. * @ORM\Column(name="name", type="string", nullable=false)
  43. */
  44. private $name;
  45. /**
  46. * @var string
  47. *
  48. * @ORM\Column(name="contact_email", type="string", nullable=false)
  49. */
  50. private $contact_email;
  51. /**
  52. * @var \DateTime
  53. *
  54. * @ORM\Column(name="created", type="datetime")
  55. *
  56. * @Gedmo\Timestampable(on="create")
  57. */
  58. private $created;
  59. /**
  60. * @var \DateTime
  61. *
  62. * @ORM\Column(name="updated", type="datetime")
  63. *
  64. * @Gedmo\Timestampable(on="update")
  65. */
  66. private $updated;
  67. /**
  68. * @var string
  69. *
  70. * @ORM\Column(name="search_index", type="text", nullable=false)
  71. */
  72. private $search_index;
  73. /**
  74. * @var \Doctrine\Common\Collections\Collection
  75. *
  76. * @ORM\OneToMany(targetEntity="MedBrief\MSR\Entity\User", mappedBy="expertAgency")
  77. */
  78. private $users;
  79. /**
  80. * Constructor
  81. */
  82. public function __construct()
  83. {
  84. $this->users = new \Doctrine\Common\Collections\ArrayCollection();
  85. }
  86. public function __toString()
  87. {
  88. return $this->getName();
  89. }
  90. /**
  91. * Get id
  92. *
  93. * @return int
  94. */
  95. public function getId()
  96. {
  97. return $this->id;
  98. }
  99. /**
  100. * Set deletedAt
  101. *
  102. * @param \DateTime $deletedAt
  103. *
  104. * @return ExpertAgency
  105. */
  106. public function setDeletedAt($deletedAt)
  107. {
  108. $this->deletedAt = $deletedAt;
  109. return $this;
  110. }
  111. /**
  112. * Get deletedAt
  113. *
  114. * @return \DateTime
  115. */
  116. public function getDeletedAt()
  117. {
  118. return $this->deletedAt;
  119. }
  120. /**
  121. * Set name
  122. *
  123. * @param string $name
  124. *
  125. * @return ExpertAgency
  126. */
  127. public function setName($name)
  128. {
  129. $this->name = $name;
  130. return $this;
  131. }
  132. /**
  133. * Get name
  134. *
  135. * @return string
  136. */
  137. public function getName()
  138. {
  139. return $this->name;
  140. }
  141. /**
  142. * Set contactEmail
  143. *
  144. * @param string $contactEmail
  145. *
  146. * @return ExpertAgency
  147. */
  148. public function setContactEmail($contactEmail)
  149. {
  150. $this->contact_email = $contactEmail;
  151. return $this;
  152. }
  153. /**
  154. * Get contactEmail
  155. *
  156. * @return string
  157. */
  158. public function getContactEmail()
  159. {
  160. return $this->contact_email;
  161. }
  162. /**
  163. * Set created
  164. *
  165. * @param \DateTime $created
  166. *
  167. * @return ExpertAgency
  168. */
  169. public function setCreated($created)
  170. {
  171. $this->created = $created;
  172. return $this;
  173. }
  174. /**
  175. * Get created
  176. *
  177. * @return \DateTime
  178. */
  179. public function getCreated()
  180. {
  181. return $this->created;
  182. }
  183. /**
  184. * Set updated
  185. *
  186. * @param \DateTime $updated
  187. *
  188. * @return ExpertAgency
  189. */
  190. public function setUpdated($updated)
  191. {
  192. $this->updated = $updated;
  193. return $this;
  194. }
  195. /**
  196. * Get updated
  197. *
  198. * @return \DateTime
  199. */
  200. public function getUpdated()
  201. {
  202. return $this->updated;
  203. }
  204. /**
  205. * Add user
  206. *
  207. * @param User $user
  208. *
  209. * @return ExpertAgency
  210. */
  211. public function addUser(User $user)
  212. {
  213. $this->users[] = $user;
  214. return $this;
  215. }
  216. /**
  217. * Remove user
  218. *
  219. * @param User $user
  220. */
  221. public function removeUser(User $user)
  222. {
  223. $this->users->removeElement($user);
  224. }
  225. /**
  226. * Get users
  227. *
  228. * @return \Doctrine\Common\Collections\Collection
  229. */
  230. public function getUsers()
  231. {
  232. return $this->users;
  233. }
  234. /**
  235. * Set searchIndex
  236. *
  237. * @param string $searchIndex
  238. *
  239. * @return ExpertAgency
  240. */
  241. public function setSearchIndex($searchIndex)
  242. {
  243. $this->search_index = $searchIndex;
  244. return $this;
  245. }
  246. /**
  247. * Get searchIndex
  248. *
  249. * @return string
  250. */
  251. public function getSearchIndex()
  252. {
  253. return $this->search_index;
  254. }
  255. /**
  256. * Updates the Search Index field with internal data. The Search Index Field
  257. * provides an easy way to perform a 'like' query for a generalised search.
  258. *
  259. * @ORM\PrePersist
  260. * @ORM\PrePersist
  261. */
  262. public function updateSearchIndex()
  263. {
  264. $searchIndex
  265. = $this->getName()
  266. . ' '
  267. . $this->getId()
  268. . ' '
  269. . $this->getContactEmail();
  270. $this->setSearchIndex($searchIndex);
  271. }
  272. }