src/Entity/Subscriber.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SubscriberRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass=SubscriberRepository::class)
  12.  * @UniqueEntity("email")
  13.  */
  14. class Subscriber
  15. {
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     
  23.     /**
  24.      * @ORM\Column(type="integer", nullable=true)
  25.      */
  26.     protected $tmpOldId;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      * @Assert\Email
  30.      */
  31.     private $email;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $name;
  36.     /**
  37.      * @ORM\Column(type="boolean")
  38.      */
  39.     private $active true;
  40.         
  41.             
  42.     /**
  43.      * @var \DateTime $createdAt
  44.      *
  45.      * @Gedmo\Timestampable(on="create")
  46.      * @ORM\Column(type="datetime", nullable=true)
  47.      */
  48.     private $createdAt;
  49.     /**
  50.      * @var \DateTime $updatedAt
  51.      *
  52.      * @Gedmo\Timestampable(on="update")
  53.      * @ORM\Column(type="datetime")
  54.      */
  55.     private $updatedAt;
  56.     /* relations */
  57.     /**
  58.      * @ORM\ManyToMany(targetEntity=SubscriberList::class, inversedBy="subscribers")
  59.      */
  60.     private $subscriberLists;
  61.     public function __construct()
  62.     {
  63.         $this->active true// default 
  64.         $this->createdAt = new \DateTime('now'); // default 
  65.         $this->updatedAt = new \DateTime('now'); // default
  66.         $this->subscriberLists = new ArrayCollection();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getTmpOldId(): ?int
  73.     {
  74.         return $this->tmpOldId;
  75.     }
  76.     public function setTmpOldId(?int $tmpOldId): self
  77.     {
  78.         $this->tmpOldId $tmpOldId;
  79.         return $this;
  80.     }
  81.     public function getEmail(): ?string
  82.     {
  83.         return $this->email;
  84.     }
  85.     public function setEmail(string $email): self
  86.     {
  87.         $this->email $email;
  88.         return $this;
  89.     }
  90.     public function getName(): ?string
  91.     {
  92.         return $this->name;
  93.     }
  94.     public function setName(?string $name): self
  95.     {
  96.         $this->name $name;
  97.         return $this;
  98.     }
  99.     public function isActive(): ?bool
  100.     {
  101.         return $this->active;
  102.     }
  103.     public function setActive(bool $active): self
  104.     {
  105.         $this->active $active;
  106.         return $this;
  107.     }
  108.     public function getCreatedAt(): ?\DateTimeInterface
  109.     {
  110.         return $this->createdAt;
  111.     }
  112.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  113.     {
  114.         $this->createdAt $createdAt;
  115.         return $this;
  116.     }
  117.     public function getUpdatedAt(): ?\DateTimeInterface
  118.     {
  119.         return $this->updatedAt;
  120.     }
  121.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  122.     {
  123.         $this->updatedAt $updatedAt;
  124.         return $this;
  125.     }
  126.     
  127.     /**
  128.      * @return Collection|SubscriberList[]
  129.      */
  130.     public function getSubscriberLists(): Collection
  131.     {
  132.         return $this->subscriberLists;
  133.     }
  134.     public function addSubscriberList(SubscriberList $subscriberList): self
  135.     {
  136.         if (!$this->subscriberLists->contains($subscriberList)) {
  137.             $this->subscriberLists[] = $subscriberList;
  138.         }
  139.         return $this;
  140.     }
  141.     public function removeSubscriberList(SubscriberList $subscriberList): self
  142.     {
  143.         if ($this->subscriberLists->contains($subscriberList)) {
  144.             $this->subscriberLists->removeElement($subscriberList);
  145.         }
  146.         return $this;
  147.     }
  148.     
  149. }