src/Entity/MailingList.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MailingListRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=MailingListRepository::class)
  9. */
  10. class MailingList
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\GeneratedValue
  15. * @ORM\Column(type="integer")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\Column(type="string", length=255)
  20. */
  21. private $content;
  22. /**
  23. * @ORM\Column(type="string", length=255, nullable=true)
  24. */
  25. private $sendgridId;
  26. /**
  27. * @ORM\OneToMany(targetEntity=User::class, mappedBy="mailingList")
  28. */
  29. private $users;
  30. /**
  31. * @ORM\Column(type="string", length=255, nullable=true)
  32. */
  33. private $segmentId;
  34. public function __construct()
  35. {
  36. $this->users = new ArrayCollection();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. public function getContent(): ?string
  43. {
  44. return $this->content;
  45. }
  46. public function setContent(string $content): self
  47. {
  48. $this->content = $content;
  49. return $this;
  50. }
  51. public function getSendgridId(): ?string
  52. {
  53. return $this->sendgridId;
  54. }
  55. public function setSendgridId(string $sendgridId): self
  56. {
  57. $this->sendgridId = $sendgridId;
  58. return $this;
  59. }
  60. /**
  61. * @return Collection<int, User>
  62. */
  63. public function getUsers(): Collection
  64. {
  65. return $this->users;
  66. }
  67. public function addUser(User $user): self
  68. {
  69. if (!$this->users->contains($user)) {
  70. $this->users[] = $user;
  71. $user->setMailingList($this);
  72. }
  73. return $this;
  74. }
  75. public function removeUser(User $user): self
  76. {
  77. if ($this->users->removeElement($user)) {
  78. // set the owning side to null (unless already changed)
  79. if ($user->getMailingList() === $this) {
  80. $user->setMailingList(null);
  81. }
  82. }
  83. return $this;
  84. }
  85. public function __toString()
  86. {
  87. return $this->content;
  88. }
  89. public function getSegmentId(): ?string
  90. {
  91. return $this->segmentId;
  92. }
  93. public function setSegmentId(string $segmentId): self
  94. {
  95. $this->segmentId = $segmentId;
  96. return $this;
  97. }
  98. }