src/Entity/Newsletter.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="App\Repository\NewsletterRepository")
  8. * @ORM\Table(name="newsletters")
  9. */
  10. class Newsletter
  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 $title;
  22. /**
  23. * @ORM\Column(type="string", length=255, nullable=true)
  24. */
  25. private $description;
  26. /**
  27. * @ORM\Column(type="integer")
  28. */
  29. private $displayOrder;
  30. /**
  31. * @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="subscriptions")
  32. */
  33. private $subscribers;
  34. public function __construct()
  35. {
  36. $this->subscribers = new ArrayCollection();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. public function getTitle(): ?string
  43. {
  44. return $this->title;
  45. }
  46. public function setTitle(string $title): self
  47. {
  48. $this->title = $title;
  49. return $this;
  50. }
  51. public function getDescription(): ?string
  52. {
  53. return $this->description;
  54. }
  55. public function setDescription(?string $description): self
  56. {
  57. $this->description = $description;
  58. return $this;
  59. }
  60. public function getDisplayOrder(): ?int
  61. {
  62. return $this->displayOrder;
  63. }
  64. public function setDisplayOrder(int $displayOrder): self
  65. {
  66. $this->displayOrder = $displayOrder;
  67. return $this;
  68. }
  69. /**
  70. * @return Collection|User[]
  71. */
  72. public function getSubscribers(): Collection
  73. {
  74. return $this->subscribers;
  75. }
  76. public function addSubscriber(User $subscriber): self
  77. {
  78. if (!$this->subscribers->contains($subscriber)) {
  79. $this->subscribers[] = $subscriber;
  80. $subscriber->addSubscription($this);
  81. }
  82. return $this;
  83. }
  84. public function removeSubscriber(User $subscriber): self
  85. {
  86. if ($this->subscribers->contains($subscriber)) {
  87. $this->subscribers->removeElement($subscriber);
  88. $subscriber->removeSubscription($this);
  89. }
  90. return $this;
  91. }
  92. }