|
- <?php
-
- namespace Lc\CaracoleBundle\Model\Newsletter;
-
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
- use Lc\SovBundle\Model\User\UserInterface;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class NewsletterModel extends AbstractFullEntity implements FilterMerchantInterface
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="newsletters")
- */
- protected $merchant;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\User\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(): ?MerchantInterface
- {
- return $this->merchant;
- }
-
- public function setMerchant(?MerchantInterface $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- /**
- * @return Collection|UserInterface[]
- */
- public function getUsers(): Collection
- {
- return $this->users;
- }
-
- public function addUser(UserInterface $user): self
- {
- if (!$this->users->contains($user)) {
- $this->users[] = $user;
- $user->addNewsletter($this);
- }
-
- return $this;
- }
-
- public function removeUser(UserInterface $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;
- }
- }
|