選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

94 行
2.2KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use App\Entity\Hub;
  4. use App\Entity\User;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Lc\ShopBundle\Context\FilterMerchantInterface;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. */
  12. abstract class Newsletter extends AbstractDocumentEntity implements FilterMerchantInterface
  13. {
  14. /**
  15. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="newsletters")
  16. */
  17. protected $merchant;
  18. /**
  19. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface", mappedBy="newsletters")
  20. */
  21. protected $users;
  22. /**
  23. * @ORM\Column(type="boolean", nullable=true)
  24. */
  25. protected $isMain;
  26. public function __toString()
  27. {
  28. return $this->getTitle() ;
  29. }
  30. public function __construct()
  31. {
  32. $this->users = new ArrayCollection();
  33. }
  34. public function getMerchant(): ?Hub
  35. {
  36. return $this->merchant;
  37. }
  38. public function setMerchant(?Hub $merchant): self
  39. {
  40. $this->merchant = $merchant;
  41. return $this;
  42. }
  43. /**
  44. * @return Collection|User[]
  45. */
  46. public function getUsers(): Collection
  47. {
  48. return $this->users;
  49. }
  50. public function addUser(User $user): self
  51. {
  52. if (!$this->users->contains($user)) {
  53. $this->users[] = $user;
  54. $user->addNewsletter($this);
  55. }
  56. return $this;
  57. }
  58. public function removeUser(User $user): self
  59. {
  60. if ($this->users->contains($user)) {
  61. $this->users->removeElement($user);
  62. $user->removeNewsletter($this);
  63. }
  64. return $this;
  65. }
  66. public function getIsMain(): ?bool
  67. {
  68. return $this->isMain;
  69. }
  70. public function setIsMain(?bool $isMain): self
  71. {
  72. $this->isMain = $isMain;
  73. return $this;
  74. }
  75. }