src/Entity/ProjectUser.php line 23

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. use MedBrief\MSR\Repository\ProjectUserRepository;
  7. /**
  8. * ProjectUser
  9. *
  10. * @ORM\Table(name="ProjectUser")
  11. *
  12. * @ORM\Entity(repositoryClass=ProjectUserRepository::class)
  13. *
  14. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  15. *
  16. * @Audit\Auditable
  17. *
  18. * @Audit\Security(view={"ROLE_ALLOWED_TO_AUDIT"})
  19. */
  20. class ProjectUser
  21. {
  22. /**
  23. * @var int
  24. *
  25. * @ORM\Column(name="id", type="integer")
  26. *
  27. * @ORM\Id
  28. *
  29. * @ORM\GeneratedValue(strategy="IDENTITY")
  30. */
  31. private $id;
  32. /**
  33. * @var \DateTime|null
  34. *
  35. * @ORM\Column(name="deletedAt", type="datetime", nullable=true)
  36. */
  37. private $deletedAt;
  38. /**
  39. * @var \DateTime
  40. *
  41. * @ORM\Column(name="created", type="datetime")
  42. *
  43. * @Gedmo\Timestampable(on="create")
  44. */
  45. private $created;
  46. /**
  47. * @var \DateTime
  48. *
  49. * @ORM\Column(name="updated", type="datetime")
  50. *
  51. * @Gedmo\Timestampable(on="update")
  52. */
  53. private $updated;
  54. /**
  55. * @var bool|null
  56. *
  57. * @ORM\Column(name="authenticated", type="boolean", nullable=true)
  58. */
  59. private $authenticated = true;
  60. /**
  61. * @var Collection
  62. *
  63. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="userPrivateCollection", cascade={"all"})
  64. *
  65. * @ORM\JoinColumns({
  66. *
  67. * @ORM\JoinColumn(name="privateCollection_id", referencedColumnName="id", unique=true)
  68. * })
  69. */
  70. private $privateCollection;
  71. /**
  72. * @var Collection
  73. *
  74. * @ORM\OneToOne(targetEntity="MedBrief\MSR\Entity\Collection", inversedBy="userPrivateSandboxCollection", cascade={"all"})
  75. *
  76. * @ORM\JoinColumns({
  77. *
  78. * @ORM\JoinColumn(name="privateSandboxCollection_id", referencedColumnName="id", unique=true)
  79. * })
  80. */
  81. private $privateSandboxCollection;
  82. /**
  83. * @var Project
  84. *
  85. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\Project", inversedBy="projectUsers")
  86. *
  87. * @ORM\JoinColumns({
  88. *
  89. * @ORM\JoinColumn(name="project_id", referencedColumnName="id")
  90. * })
  91. */
  92. private $project;
  93. /**
  94. * @var User
  95. *
  96. * @ORM\ManyToOne(targetEntity="MedBrief\MSR\Entity\User", inversedBy="projectUsers")
  97. *
  98. * @ORM\JoinColumns({
  99. *
  100. * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  101. * })
  102. */
  103. private $user;
  104. public function __toString()
  105. {
  106. return (string) $this->getId();
  107. }
  108. /**
  109. * Get id
  110. *
  111. * @return int
  112. */
  113. public function getId()
  114. {
  115. return $this->id;
  116. }
  117. /**
  118. * Set deletedAt
  119. *
  120. * @param \DateTime $deletedAt
  121. *
  122. * @return ProjectUser
  123. */
  124. public function setDeletedAt($deletedAt)
  125. {
  126. $this->deletedAt = $deletedAt;
  127. return $this;
  128. }
  129. /**
  130. * Get deletedAt
  131. *
  132. * @return \DateTime
  133. */
  134. public function getDeletedAt()
  135. {
  136. return $this->deletedAt;
  137. }
  138. /**
  139. * Set created
  140. *
  141. * @param \DateTime $created
  142. *
  143. * @return ProjectUser
  144. */
  145. public function setCreated($created)
  146. {
  147. $this->created = $created;
  148. return $this;
  149. }
  150. /**
  151. * Get created
  152. *
  153. * @return \DateTime
  154. */
  155. public function getCreated()
  156. {
  157. return $this->created;
  158. }
  159. /**
  160. * Set updated
  161. *
  162. * @param \DateTime $updated
  163. *
  164. * @return ProjectUser
  165. */
  166. public function setUpdated($updated)
  167. {
  168. $this->updated = $updated;
  169. return $this;
  170. }
  171. /**
  172. * Get updated
  173. *
  174. * @return \DateTime
  175. */
  176. public function getUpdated()
  177. {
  178. return $this->updated;
  179. }
  180. /**
  181. * Set project
  182. *
  183. * @param Project $project
  184. *
  185. * @return ProjectUser
  186. */
  187. public function setProject(?Project $project = null)
  188. {
  189. $this->project = $project;
  190. return $this;
  191. }
  192. /**
  193. * Get project
  194. *
  195. * @return Project
  196. */
  197. public function getProject()
  198. {
  199. return $this->project;
  200. }
  201. /**
  202. * Set user
  203. *
  204. * @param User $user
  205. *
  206. * @return ProjectUser
  207. */
  208. public function setUser(?User $user = null)
  209. {
  210. $this->user = $user;
  211. // When we change the user, we should also change the collection names to the new user.
  212. if ($user) {
  213. // Set the PrivateCollection name to that of the user's fullname
  214. if ($this->privateCollection) {
  215. $this->privateCollection->setName($user->getFullName());
  216. }
  217. // Set the PrivateSandboxCollection name to that of the user's fullname
  218. if ($this->privateSandboxCollection) {
  219. $this->privateSandboxCollection->setName($user->getFullName());
  220. }
  221. }
  222. return $this;
  223. }
  224. /**
  225. * Get user
  226. *
  227. * @return User
  228. */
  229. public function getUser()
  230. {
  231. return $this->user;
  232. }
  233. /**
  234. * Set privateCollection
  235. *
  236. * @param Collection $privateCollection
  237. *
  238. * @return ProjectUser
  239. */
  240. public function setPrivateCollection(?Collection $privateCollection = null)
  241. {
  242. $this->privateCollection = $privateCollection;
  243. return $this;
  244. }
  245. /**
  246. * Get privateCollection
  247. *
  248. * @return Collection
  249. */
  250. public function getPrivateCollection()
  251. {
  252. return $this->privateCollection;
  253. }
  254. /**
  255. * Set privateSandboxCollection
  256. *
  257. * @param Collection $privateSandboxCollection
  258. *
  259. * @return ProjectUser
  260. */
  261. public function setPrivateSandboxCollection(?Collection $privateSandboxCollection = null)
  262. {
  263. $this->privateSandboxCollection = $privateSandboxCollection;
  264. return $this;
  265. }
  266. /**
  267. * Get privateSandboxCollection
  268. *
  269. * @return Collection
  270. */
  271. public function getPrivateSandboxCollection()
  272. {
  273. return $this->privateSandboxCollection;
  274. }
  275. /**
  276. * Set authenticated.
  277. *
  278. * @param bool $authenticated
  279. *
  280. * @return ProjectUser
  281. */
  282. public function setAuthenticated($authenticated)
  283. {
  284. $this->authenticated = $authenticated;
  285. return $this;
  286. }
  287. /**
  288. * Get authenticated.
  289. *
  290. * @return bool
  291. */
  292. public function getAuthenticated()
  293. {
  294. return $this->authenticated;
  295. }
  296. }