Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

77 linhas
1.9KB

  1. <?php
  2. namespace App\Entity\User;
  3. use App\Entity\CollectifData\CollectifData;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Lc\SovBundle\Model\User\UserModel as SovUserModel;
  8. use Lc\SovBundle\Model\User\UserInterface;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11. * @ORM\Entity(repositoryClass="Lc\SovBundle\Repository\User\UserRepository")
  12. * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  13. */
  14. class User extends SovUserModel implements UserInterface
  15. {
  16. /**
  17. * @ORM\Id
  18. * @ORM\GeneratedValue
  19. * @ORM\Column(type="integer")
  20. */
  21. private $id;
  22. /**
  23. * @ORM\OneToMany(targetEntity=CollectifData::class, mappedBy="user")
  24. */
  25. private $collectifData;
  26. public function __construct()
  27. {
  28. $this->collectifData = new ArrayCollection();
  29. }
  30. public function __toString()
  31. {
  32. return $this->firstname . " " . $this->lastname;
  33. }
  34. public function getId(): ?int
  35. {
  36. return $this->id;
  37. }
  38. /**
  39. * @return Collection|CollectifData[]
  40. */
  41. public function getCollectifData(): Collection
  42. {
  43. return $this->collectifData;
  44. }
  45. public function addCollectifData(CollectifData $collectifData): self
  46. {
  47. if (!$this->collectifData->contains($collectifData)) {
  48. $this->collectifData[] = $collectifData;
  49. $collectifData->setUser($this);
  50. }
  51. return $this;
  52. }
  53. public function removeCollectifData(CollectifData $collectifData): self
  54. {
  55. if ($this->collectifData->removeElement($collectifData)) {
  56. // set the owning side to null (unless already changed)
  57. if ($collectifData->getUser() === $this) {
  58. $collectifData->setUser(null);
  59. }
  60. }
  61. return $this;
  62. }
  63. }