|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use App\Entity\Hub;
- use App\Entity\User;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\FilterMerchantInterface;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class Newsletter extends AbstractDocumentEntity implements FilterMerchantInterface
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="newsletters")
- */
- protected $merchant;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface", mappedBy="newsletters")
- */
- protected $users;
-
- /**
- * @ORM\Column(type="boolean", nullable=true)
- */
- protected $isMain;
-
- public function __toString()
- {
- return $this->getTitle() ;
- }
-
- public function __construct()
- {
- $this->users = new ArrayCollection();
- }
-
- public function getMerchant(): ?Hub
- {
- return $this->merchant;
- }
-
- public function setMerchant(?Hub $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- /**
- * @return Collection|User[]
- */
- public function getUsers(): Collection
- {
- return $this->users;
- }
-
- public function addUser(User $user): self
- {
- if (!$this->users->contains($user)) {
- $this->users[] = $user;
- $user->addNewsletter($this);
- }
-
- return $this;
- }
-
- public function removeUser(User $user): self
- {
- if ($this->users->contains($user)) {
- $this->users->removeElement($user);
- $user->removeNewsletter($this);
- }
-
- return $this;
- }
-
- public function getIsMain(): ?bool
- {
- return $this->isMain;
- }
-
- public function setIsMain(?bool $isMain): self
- {
- $this->isMain = $isMain;
-
- return $this;
- }
- }
|