src/Entity/AppUser.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AppUserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClass: AppUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
  12. class AppUser implements UserInterface, PasswordAuthenticatedUserInterface
  13. {
  14. #[ORM\Id]
  15. #[ORM\GeneratedValue]
  16. #[ORM\Column(type: 'integer')]
  17. private $id;
  18. #[ORM\Column(type: 'string', length: 180, unique: true)]
  19. private ?string $email = null;
  20. #[ORM\Column(type: 'json')]
  21. private array $roles = [];
  22. #[ORM\Column(type: 'string')]
  23. private ?string $password = null;
  24. #[ORM\OneToMany(targetEntity: VesselIssue::class, mappedBy: 'app_user')]
  25. private Collection|array $vesselIssues;
  26. #[ORM\OneToMany(targetEntity: VesselComparison::class, mappedBy: 'app_user')]
  27. private Collection|array $vesselComparisons;
  28. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  29. private ?string $name_first = null;
  30. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  31. private ?string $name_last = null;
  32. #[ORM\Column(type: 'string', length: 10, nullable: true)]
  33. private ?string $name_prefix = null;
  34. #[ORM\Column(type: 'string', length: 10, nullable: true)]
  35. private ?string $address_country = null;
  36. #[ORM\Column(type: 'string', length: 60, nullable: true)]
  37. private ?string $address_region = null;
  38. #[ORM\Column(type: 'string', length: 15, nullable: true)]
  39. private ?string $address_zip = null;
  40. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  41. private ?string $address_city = null;
  42. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  43. private ?string $address_line1 = null;
  44. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  45. private ?string $address_line2 = null;
  46. #[ORM\Column(type: 'string', length: 15, nullable: true)]
  47. private ?string $bank_swift = null;
  48. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  49. private ?string $bank_iban = null;
  50. #[ORM\Column(type: 'datetime', nullable: true)]
  51. private ?\DateTimeInterface $date_birth = null;
  52. #[ORM\OneToMany(targetEntity: AssignmentLog::class, mappedBy: 'app_user')]
  53. private Collection|array $assignmentLog;
  54. #[ORM\OneToMany(targetEntity: Bookmark::class, mappedBy: 'app_user')]
  55. private Collection|array $bookmarks;
  56. #[ORM\Column(type: 'string', length: 100, nullable: true)]
  57. private ?string $xp_level = null;
  58. #[ORM\Column(type: 'integer', nullable: true)]
  59. private ?int $xp_years = null;
  60. #[ORM\OneToMany(targetEntity: RedeemRequest::class, mappedBy: 'app_user', orphanRemoval: true)]
  61. private Collection|array $redeemRequests;
  62. #[ORM\OneToMany(targetEntity: AssignmentTasks::class, mappedBy: 'AppUser', orphanRemoval: true)]
  63. private Collection|array $assignmentTasks;
  64. #[ORM\OneToMany(targetEntity: Assignment::class, mappedBy: 'app_user', orphanRemoval: true)]
  65. private Collection|array $assignments;
  66. #[ORM\OneToMany(targetEntity: VesselErrorLog::class, mappedBy: 'reported_by')]
  67. private Collection|array $vesselErrorLogs;
  68. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: QuizEntry::class, orphanRemoval: true)]
  69. private Collection $quizEntries;
  70. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: MyWoundSuture::class)]
  71. private Collection $myWoundSutures;
  72. #[ORM\ManyToMany(targetEntity: Course::class, mappedBy: 'users')]
  73. #[ORM\OrderBy(['name' => 'ASC'])]
  74. private Collection $courses;
  75. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: TrainEntry::class, orphanRemoval: true)]
  76. private Collection $trainEntries;
  77. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: ExcelEntry::class, orphanRemoval: true)]
  78. private Collection $excelEntries;
  79. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: ModuleProgess::class, orphanRemoval: true)]
  80. private Collection $moduleProgesses;
  81. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: IntroEntry::class, orphanRemoval: true)]
  82. private Collection $introEntries;
  83. #[ORM\OneToMany(mappedBy: 'app_user', targetEntity: CourseModuleUser::class, orphanRemoval: true)]
  84. private Collection $courseModuleUsers;
  85. public function __construct()
  86. {
  87. $this->quizEntries = new ArrayCollection();
  88. $this->trainEntries = new ArrayCollection();
  89. $this->excelEntries = new ArrayCollection();
  90. $this->moduleProgesses = new ArrayCollection();
  91. $this->introEntries = new ArrayCollection();
  92. $this->courseModuleUsers = new ArrayCollection();
  93. }
  94. public function getId(): ?int
  95. {
  96. return $this->id;
  97. }
  98. public function getEmail(): ?string
  99. {
  100. return $this->email;
  101. }
  102. public function setEmail(string $email): self
  103. {
  104. $this->email = $email;
  105. return $this;
  106. }
  107. /**
  108. * A visual identifier that represents this user.
  109. *
  110. * @see UserInterface
  111. */
  112. public function getUsername(): string
  113. {
  114. return (string) $this->email;
  115. }
  116. /**
  117. * A visual identifier that represents this user.
  118. *
  119. * @see UserInterface
  120. */
  121. public function getUserIdentifier(): string
  122. {
  123. return (string) $this->email;
  124. }
  125. /**
  126. * @see UserInterface
  127. */
  128. public function getRoles(): array
  129. {
  130. $roles = $this->roles;
  131. // guarantee every user at least has ROLE_USER
  132. $roles[] = 'ROLE_USER';
  133. return array_unique($roles);
  134. }
  135. public function setRoles(array $roles): self
  136. {
  137. $this->roles = $roles;
  138. return $this;
  139. }
  140. /**
  141. * @see PasswordAuthenticatedUserInterface
  142. */
  143. public function getPassword(): ?string
  144. {
  145. return $this->password;
  146. }
  147. public function setPassword(string $password): self
  148. {
  149. $this->password = $password;
  150. return $this;
  151. }
  152. /**
  153. * Returning a salt is only needed, if you are not using a modern
  154. * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  155. *
  156. * @see UserInterface
  157. */
  158. public function getSalt(): ?string
  159. {
  160. return null;
  161. }
  162. /**
  163. * @see UserInterface
  164. */
  165. public function eraseCredentials()
  166. {
  167. // If you store any temporary, sensitive data on the user, clear it here
  168. // $this->plainPassword = null;
  169. }
  170. public function isComplete()
  171. {
  172. return
  173. !empty($this->getNameFirst()) &&
  174. !empty($this->getNameLast()) &&
  175. !(empty($this->getXpYears()) && $this->getXpYears()!==0 ) &&
  176. !empty($this->getXpLevel()) &&
  177. !empty($this->getDateBirth())
  178. ;
  179. }
  180. /**
  181. * @return Collection|VesselIssue[]
  182. */
  183. public function getVesselIssues(): Collection
  184. {
  185. return $this->vesselIssues;
  186. }
  187. public function addVesselIssue(VesselIssue $vesselIssue): self
  188. {
  189. if (!$this->vesselIssues->contains($vesselIssue)) {
  190. $this->vesselIssues[] = $vesselIssue;
  191. $vesselIssue->setAppUser($this);
  192. }
  193. return $this;
  194. }
  195. public function removeVesselIssue(VesselIssue $vesselIssue): self
  196. {
  197. if ($this->vesselIssues->removeElement($vesselIssue)) {
  198. // set the owning side to null (unless already changed)
  199. if ($vesselIssue->getAppUser() === $this) {
  200. $vesselIssue->setAppUser(null);
  201. }
  202. }
  203. return $this;
  204. }
  205. /**
  206. * @return Collection|VesselComparison[]
  207. */
  208. public function getVesselComparisons(): Collection
  209. {
  210. return $this->vesselComparisons;
  211. }
  212. public function addVesselComparison(VesselComparison $vesselComparison): self
  213. {
  214. if (!$this->vesselComparisons->contains($vesselComparison)) {
  215. $this->vesselComparisons[] = $vesselComparison;
  216. $vesselComparison->setAppUser($this);
  217. }
  218. return $this;
  219. }
  220. public function removeVesselComparison(VesselComparison $vesselComparison): self
  221. {
  222. if ($this->vesselComparisons->removeElement($vesselComparison)) {
  223. // set the owning side to null (unless already changed)
  224. if ($vesselComparison->getAppUser() === $this) {
  225. $vesselComparison->setAppUser(null);
  226. }
  227. }
  228. return $this;
  229. }
  230. public function getNameFirst(): ?string
  231. {
  232. return $this->name_first;
  233. }
  234. public function setNameFirst(string $name_first): self
  235. {
  236. $this->name_first = $name_first;
  237. return $this;
  238. }
  239. public function getNameLast(): ?string
  240. {
  241. return $this->name_last;
  242. }
  243. public function setNameLast(?string $name_last): self
  244. {
  245. $this->name_last = $name_last;
  246. return $this;
  247. }
  248. public function getNamePrefix(): ?string
  249. {
  250. return $this->name_prefix;
  251. }
  252. public function setNamePrefix(?string $name_prefix): self
  253. {
  254. $this->name_prefix = $name_prefix;
  255. return $this;
  256. }
  257. public function getNameFull(): ?string
  258. {
  259. $name = $this->name_prefix;
  260. $name .= strlen((string) $this->name_prefix) > 0 ? ' ' : '';
  261. $name .= $this->name_first;
  262. $name .= ' '.$this->name_last;
  263. return $name;
  264. }
  265. public function getAddressCountry(): ?string
  266. {
  267. return $this->address_country;
  268. }
  269. public function setAddressCountry(?string $address_country): self
  270. {
  271. $this->address_country = $address_country;
  272. return $this;
  273. }
  274. public function getAddressRegion(): ?string
  275. {
  276. return $this->address_region;
  277. }
  278. public function setAddressRegion(?string $address_region): self
  279. {
  280. $this->address_region = $address_region;
  281. return $this;
  282. }
  283. public function getAddressZip(): ?string
  284. {
  285. return $this->address_zip;
  286. }
  287. public function setAddressZip(?string $address_zip): self
  288. {
  289. $this->address_zip = $address_zip;
  290. return $this;
  291. }
  292. public function getAddressCity(): ?string
  293. {
  294. return $this->address_city;
  295. }
  296. public function setAddressCity(?string $address_city): self
  297. {
  298. $this->address_city = $address_city;
  299. return $this;
  300. }
  301. public function getAddressLine1(): ?string
  302. {
  303. return $this->address_line1;
  304. }
  305. public function setAddressLine1(?string $address_line1): self
  306. {
  307. $this->address_line1 = $address_line1;
  308. return $this;
  309. }
  310. public function getAddressLine2(): ?string
  311. {
  312. return $this->address_line2;
  313. }
  314. public function setAddressLine2(?string $address_line2): self
  315. {
  316. $this->address_line2 = $address_line2;
  317. return $this;
  318. }
  319. public function getBankSwift(): ?string
  320. {
  321. return $this->bank_swift;
  322. }
  323. public function setBankSwift(?string $bank_swift): self
  324. {
  325. $this->bank_swift = $bank_swift;
  326. return $this;
  327. }
  328. public function getBankIban(): ?string
  329. {
  330. return $this->bank_iban;
  331. }
  332. public function setBankIban(?string $bank_iban): self
  333. {
  334. $this->bank_iban = $bank_iban;
  335. return $this;
  336. }
  337. public function getDateBirth(): ?\DateTimeInterface
  338. {
  339. return $this->date_birth;
  340. }
  341. public function setDateBirth(?\DateTimeInterface $date_birth): self
  342. {
  343. $this->date_birth = $date_birth;
  344. return $this;
  345. }
  346. /**
  347. * @return Collection|AssignmentLog[]
  348. */
  349. public function getAssignmentLog(): Collection
  350. {
  351. return $this->assignmentLog;
  352. }
  353. public function addAssignmentLog(AssignmentLog $assignmentLog): self
  354. {
  355. if (!$this->assignmentLog->contains($assignmentLog)) {
  356. $this->assignmentLog[] = $assignmentLog;
  357. $assignmentLog->setAppUser($this);
  358. }
  359. return $this;
  360. }
  361. public function removeAssignmentLog(AssignmentLog $assignmentLog): self
  362. {
  363. if ($this->assignmentLog->removeElement($assignmentLog)) {
  364. // set the owning side to null (unless already changed)
  365. if ($assignmentLog->getAppUser() === $this) {
  366. $assignmentLog->setAppUser(null);
  367. }
  368. }
  369. return $this;
  370. }
  371. /**
  372. * @return Collection|Bookmark[]
  373. */
  374. public function getBookmarks(): Collection
  375. {
  376. return $this->bookmarks;
  377. }
  378. public function addBookmark(Bookmark $bookmark): self
  379. {
  380. if (!$this->bookmarks->contains($bookmark)) {
  381. $this->bookmarks[] = $bookmark;
  382. $bookmark->setAppUser($this);
  383. }
  384. return $this;
  385. }
  386. public function removeBookmark(Bookmark $bookmark): self
  387. {
  388. if ($this->bookmarks->removeElement($bookmark)) {
  389. // set the owning side to null (unless already changed)
  390. if ($bookmark->getAppUser() === $this) {
  391. $bookmark->setAppUser(null);
  392. }
  393. }
  394. return $this;
  395. }
  396. public function getXpLevel(): ?string
  397. {
  398. return $this->xp_level;
  399. }
  400. public function setXpLevel(?string $xp_level): self
  401. {
  402. $this->xp_level = $xp_level;
  403. return $this;
  404. }
  405. public function getXpYears(): ?int
  406. {
  407. return $this->xp_years;
  408. }
  409. public function setXpYears(?int $xp_years): self
  410. {
  411. $this->xp_years = $xp_years;
  412. return $this;
  413. }
  414. /**
  415. * @return Collection|RedeemRequest[]
  416. */
  417. public function getRedeemRequests(): Collection
  418. {
  419. return $this->redeemRequests;
  420. }
  421. public function addRedeemRequest(RedeemRequest $redeemRequest): self
  422. {
  423. if (!$this->redeemRequests->contains($redeemRequest)) {
  424. $this->redeemRequests[] = $redeemRequest;
  425. $redeemRequest->setAppUser($this);
  426. }
  427. return $this;
  428. }
  429. public function removeRedeemRequest(RedeemRequest $redeemRequest): self
  430. {
  431. if ($this->redeemRequests->removeElement($redeemRequest)) {
  432. // set the owning side to null (unless already changed)
  433. if ($redeemRequest->getAppUser() === $this) {
  434. $redeemRequest->setAppUser(null);
  435. }
  436. }
  437. return $this;
  438. }
  439. /**
  440. * @return Collection|AssignmentTasks[]
  441. */
  442. public function getAssignmentTasks(): Collection
  443. {
  444. return $this->assignmentTasks;
  445. }
  446. public function addAssignmentTask(AssignmentTasks $assignmentTask): self
  447. {
  448. if (!$this->assignmentTasks->contains($assignmentTask)) {
  449. $this->assignmentTasks[] = $assignmentTask;
  450. $assignmentTask->setAppUser($this);
  451. }
  452. return $this;
  453. }
  454. public function removeAssignmentTask(AssignmentTasks $assignmentTask): self
  455. {
  456. if ($this->assignmentTasks->removeElement($assignmentTask)) {
  457. // set the owning side to null (unless already changed)
  458. if ($assignmentTask->getAppUser() === $this) {
  459. $assignmentTask->setAppUser(null);
  460. }
  461. }
  462. return $this;
  463. }
  464. /**
  465. * @return Collection|Assignment[]
  466. */
  467. public function getAssignments(): Collection
  468. {
  469. return $this->assignments;
  470. }
  471. public function addAssignment(Assignment $assignment): self
  472. {
  473. if (!$this->assignments->contains($assignment)) {
  474. $this->assignments[] = $assignment;
  475. $assignment->setAppUser($this);
  476. }
  477. return $this;
  478. }
  479. public function removeAssignment(Assignment $assignment): self
  480. {
  481. if ($this->assignments->removeElement($assignment)) {
  482. // set the owning side to null (unless already changed)
  483. if ($assignment->getAppUser() === $this) {
  484. $assignment->setAppUser(null);
  485. }
  486. }
  487. return $this;
  488. }
  489. /**
  490. * @return Collection|VesselErrorLog[]
  491. */
  492. public function getVesselErrorLogs(): Collection
  493. {
  494. return $this->vesselErrorLogs;
  495. }
  496. public function addVesselErrorLog(VesselErrorLog $vesselErrorLog): self
  497. {
  498. if (!$this->vesselErrorLogs->contains($vesselErrorLog)) {
  499. $this->vesselErrorLogs[] = $vesselErrorLog;
  500. $vesselErrorLog->setReportedBy($this);
  501. }
  502. return $this;
  503. }
  504. public function removeVesselErrorLog(VesselErrorLog $vesselErrorLog): self
  505. {
  506. if ($this->vesselErrorLogs->removeElement($vesselErrorLog)) {
  507. // set the owning side to null (unless already changed)
  508. if ($vesselErrorLog->getReportedBy() === $this) {
  509. $vesselErrorLog->setReportedBy(null);
  510. }
  511. }
  512. return $this;
  513. }
  514. /**
  515. * @return Collection<int, QuizEntry>
  516. */
  517. public function getQuizEntries(): Collection
  518. {
  519. return $this->quizEntries;
  520. }
  521. public function addQuizEntry(QuizEntry $quizEntry): self
  522. {
  523. if (!$this->quizEntries->contains($quizEntry)) {
  524. $this->quizEntries->add($quizEntry);
  525. $quizEntry->setAppUser($this);
  526. }
  527. return $this;
  528. }
  529. public function removeQuizEntry(QuizEntry $quizEntry): self
  530. {
  531. if ($this->quizEntries->removeElement($quizEntry)) {
  532. // set the owning side to null (unless already changed)
  533. if ($quizEntry->getAppUser() === $this) {
  534. $quizEntry->setAppUser(null);
  535. }
  536. }
  537. return $this;
  538. }
  539. /**
  540. * @return Collection<int, MyWoundSuture>
  541. */
  542. public function getMyWoundSutures(): Collection
  543. {
  544. return $this->myWoundSutures;
  545. }
  546. public function addMyWoundSuture(MyWoundSuture $myWoundSuture): self
  547. {
  548. if (!$this->myWoundSutures->contains($myWoundSuture)) {
  549. $this->myWoundSutures->add($myWoundSuture);
  550. $myWoundSuture->setAppUser($this);
  551. }
  552. return $this;
  553. }
  554. public function removeMyWoundSuture(MyWoundSuture $myWoundSuture): self
  555. {
  556. if ($this->myWoundSutures->removeElement($myWoundSuture)) {
  557. // set the owning side to null (unless already changed)
  558. if ($myWoundSuture->getAppUser() === $this) {
  559. $myWoundSuture->setAppUser(null);
  560. }
  561. }
  562. return $this;
  563. }
  564. /**
  565. * @return Collection<int, Course>
  566. */
  567. public function getCourses(): Collection
  568. {
  569. return $this->courses;
  570. }
  571. public function addCourse(Course $course): self
  572. {
  573. if (!$this->courses->contains($course)) {
  574. $this->courses->add($course);
  575. $course->addUser($this);
  576. }
  577. return $this;
  578. }
  579. public function removeCourse(Course $course): self
  580. {
  581. if ($this->courses->removeElement($course)) {
  582. $course->removeUser($this);
  583. }
  584. return $this;
  585. }
  586. /**
  587. * @return Collection<int, TrainEntry>
  588. */
  589. public function getTrainEntries(): Collection
  590. {
  591. return $this->trainEntries;
  592. }
  593. public function addTrainEntry(TrainEntry $trainEntry): self
  594. {
  595. if (!$this->trainEntries->contains($trainEntry)) {
  596. $this->trainEntries->add($trainEntry);
  597. $trainEntry->setAppUser($this);
  598. }
  599. return $this;
  600. }
  601. public function removeTrainEntry(TrainEntry $trainEntry): self
  602. {
  603. if ($this->trainEntries->removeElement($trainEntry)) {
  604. // set the owning side to null (unless already changed)
  605. if ($trainEntry->getAppUser() === $this) {
  606. $trainEntry->setAppUser(null);
  607. }
  608. }
  609. return $this;
  610. }
  611. /**
  612. * @return Collection<int, ExcelEntry>
  613. */
  614. public function getExcelEntries(): Collection
  615. {
  616. return $this->excelEntries;
  617. }
  618. public function addExcelEntry(ExcelEntry $excelEntry): static
  619. {
  620. if (!$this->excelEntries->contains($excelEntry)) {
  621. $this->excelEntries->add($excelEntry);
  622. $excelEntry->setAppUser($this);
  623. }
  624. return $this;
  625. }
  626. public function removeExcelEntry(ExcelEntry $excelEntry): static
  627. {
  628. if ($this->excelEntries->removeElement($excelEntry)) {
  629. // set the owning side to null (unless already changed)
  630. if ($excelEntry->getAppUser() === $this) {
  631. $excelEntry->setAppUser(null);
  632. }
  633. }
  634. return $this;
  635. }
  636. /**
  637. * @return Collection<int, ModuleProgess>
  638. */
  639. public function getModuleProgesses(): Collection
  640. {
  641. return $this->moduleProgesses;
  642. }
  643. public function addModuleProgess(ModuleProgess $moduleProgess): static
  644. {
  645. if (!$this->moduleProgesses->contains($moduleProgess)) {
  646. $this->moduleProgesses->add($moduleProgess);
  647. $moduleProgess->setAppUser($this);
  648. }
  649. return $this;
  650. }
  651. public function removeModuleProgess(ModuleProgess $moduleProgess): static
  652. {
  653. if ($this->moduleProgesses->removeElement($moduleProgess)) {
  654. // set the owning side to null (unless already changed)
  655. if ($moduleProgess->getAppUser() === $this) {
  656. $moduleProgess->setAppUser(null);
  657. }
  658. }
  659. return $this;
  660. }
  661. /**
  662. * @return Collection<int, IntroEntry>
  663. */
  664. public function getIntroEntries(): Collection
  665. {
  666. return $this->introEntries;
  667. }
  668. public function addIntroEntry(IntroEntry $introEntry): static
  669. {
  670. if (!$this->introEntries->contains($introEntry)) {
  671. $this->introEntries->add($introEntry);
  672. $introEntry->setAppUser($this);
  673. }
  674. return $this;
  675. }
  676. public function removeIntroEntry(IntroEntry $introEntry): static
  677. {
  678. if ($this->introEntries->removeElement($introEntry)) {
  679. // set the owning side to null (unless already changed)
  680. if ($introEntry->getAppUser() === $this) {
  681. $introEntry->setAppUser(null);
  682. }
  683. }
  684. return $this;
  685. }
  686. /**
  687. * @return Collection<int, CourseModuleUser>
  688. */
  689. public function getCourseModuleUsers(): Collection
  690. {
  691. return $this->courseModuleUsers;
  692. }
  693. public function addCourseModuleUser(CourseModuleUser $courseModuleUser): static
  694. {
  695. if (!$this->courseModuleUsers->contains($courseModuleUser)) {
  696. $this->courseModuleUsers->add($courseModuleUser);
  697. $courseModuleUser->setAppUser($this);
  698. }
  699. return $this;
  700. }
  701. public function removeCourseModuleUser(CourseModuleUser $courseModuleUser): static
  702. {
  703. if ($this->courseModuleUsers->removeElement($courseModuleUser)) {
  704. // set the owning side to null (unless already changed)
  705. if ($courseModuleUser->getAppUser() === $this) {
  706. $courseModuleUser->setAppUser(null);
  707. }
  708. }
  709. return $this;
  710. }
  711. }