No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

95 líneas
2.1KB

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