src/Entity/Newsletter.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\NewsletterRepository")
  8.  *
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class Newsletter
  12. {
  13.     public function __construct()
  14.     {
  15.         $this->subscribers = new ArrayCollection();
  16.         $this->articles = new ArrayCollection();
  17.         $this->categories = new ArrayCollection();
  18.         $this->advertisingBanners = new ArrayCollection();
  19.         $this->advertisingBannerContainers = new ArrayCollection();
  20.     }
  21.     /**
  22.      * @ORM\Id()
  23.      *
  24.      * @ORM\GeneratedValue()
  25.      *
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="string", nullable=true, length=180)
  31.      */
  32.     private $name null;
  33.     /**
  34.      * @ORM\Column(type="integer", nullable=false)
  35.      */
  36.     private $publication_status 0;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity="App\Entity\NewsletterSubscriber", mappedBy="newsletter")
  39.      */
  40.     private $subscribers;
  41.     /**
  42.      * @ORM\Column(type="boolean")
  43.      */
  44.     private $manual false;
  45.     /**
  46.      * @ORM\Column(type="boolean")
  47.      */
  48.     private $private true;
  49.     /**
  50.      * @ORM\Column(type="datetime")
  51.      */
  52.     private $schedule;
  53.     /**
  54.      * @ORM\Column(type="date", nullable=true)
  55.      */
  56.     private $schedule_date;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private $frequency;
  61.     /**
  62.      * @ORM\Column(type="text", nullable=true)
  63.      */
  64.     private $frequency_data;
  65.     /**
  66.      * @ORM\Column(type="integer", nullable=true)
  67.      */
  68.     private $articles_count;
  69.     /**
  70.      * @ORM\Column(type="integer", nullable=true)
  71.      */
  72.     private $max_article_age;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity="App\Entity\NewsletterArticle", mappedBy="newsletter")
  75.      */
  76.     private $articles;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\NewsletterCategory", mappedBy="newsletter")
  79.      */
  80.     private $categories;
  81.     /**
  82.      * @ORM\Column(type="datetime", nullable=false)
  83.      */
  84.     private $created_at;
  85.     /**
  86.      * @ORM\Column(type="datetime", nullable=true)
  87.      */
  88.     private $updated_at null;
  89.     /**
  90.      * @ORM\Column(type="datetime", nullable=true)
  91.      */
  92.     private $deleted_at;
  93.     /**
  94.      * @ORM\Column(type="integer", nullable=false)
  95.      */
  96.     private $is_default 0;
  97.     /**
  98.      * @ORM\OneToMany(targetEntity="App\Entity\AdvertisingBanner", mappedBy="newsletter")
  99.      */
  100.     private $advertisingBanners;
  101.     /**
  102.      * @ORM\OneToMany(targetEntity="App\Entity\AdvertisingBanner", mappedBy="target_newsletter")
  103.      */
  104.     private $advertisingBannerContainers;
  105.     /**
  106.      * @ORM\ManyToOne(targetEntity="App\Entity\Offer", inversedBy="newsletters")
  107.      *
  108.      * @ORM\JoinColumn(nullable=true)
  109.      */
  110.     private $offer null;
  111.     /**
  112.      * @ORM\Column(type="string", nullable=true, length=180)
  113.      */
  114.     private $sender_email;
  115.     /**
  116.      * @ORM\Column(type="string", nullable=true, length=180)
  117.      */
  118.     private $sender_name;
  119.     public function getId(): ?int
  120.     {
  121.         return $this->id;
  122.     }
  123.     public function getOffer(): ?Offer
  124.     {
  125.         return $this->offer;
  126.     }
  127.     public function setOffer(?Offer $offer): self
  128.     {
  129.         $this->offer $offer;
  130.         return $this;
  131.     }
  132.     public function getName()
  133.     {
  134.         return $this->name;
  135.     }
  136.     public function setName($name)
  137.     {
  138.         $this->name $name;
  139.         return $this;
  140.     }
  141.     public function getPublicationStatus()
  142.     {
  143.         return $this->publication_status;
  144.     }
  145.     public function setPublicationStatus($publication_status)
  146.     {
  147.         $this->publication_status $publication_status;
  148.         return $this;
  149.     }
  150.     public function getCreatedAt(): \DateTimeInterface
  151.     {
  152.         return $this->created_at;
  153.     }
  154.     public function setCreatedAt(\DateTimeInterface $created_at): self
  155.     {
  156.         $this->created_at $created_at;
  157.         return $this;
  158.     }
  159.     public function getUpdatedAt(): ?\DateTimeInterface
  160.     {
  161.         return $this->updated_at;
  162.     }
  163.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  164.     {
  165.         $this->updated_at $updated_at;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @ORM\PrePersist
  170.      */
  171.     public function setCreatedAtValue()
  172.     {
  173.         $this->setCreatedAt(new \DateTime());
  174.     }
  175.     /**
  176.      * @ORM\PreUpdate
  177.      */
  178.     public function setUpdatedAtValue()
  179.     {
  180.         $this->setUpdatedAt(new \DateTime());
  181.     }
  182.     public function getDeletedAt(): ?\DateTimeInterface
  183.     {
  184.         return $this->deleted_at;
  185.     }
  186.     public function setDeletedAt(?\DateTimeInterface $deleted_at): self
  187.     {
  188.         $this->deleted_at $deleted_at;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection|NewsletterSubscriber[]
  193.      */
  194.     public function getSubscribers(): Collection
  195.     {
  196.         return $this->subscribers;
  197.     }
  198.     public function addSubscriber(NewsletterSubscriber $subscriber): self
  199.     {
  200.         if (!$this->subscribers->contains($subscriber)) {
  201.             $this->subscribers[] = $subscriber;
  202.             $subscriber->setNewsletter($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeSubscriber(NewsletterSubscriber $subscriber): self
  207.     {
  208.         if ($this->subscribers->contains($subscriber)) {
  209.             $this->subscribers->removeElement($subscriber);
  210.             // set the owning side to null (unless already changed)
  211.             if ($subscriber->getNewsletter() === $this) {
  212.                 $subscriber->setNewsletter(null);
  213.             }
  214.         }
  215.         return $this;
  216.     }
  217.     public function getManual(): ?bool
  218.     {
  219.         return $this->manual;
  220.     }
  221.     public function setManual(bool $manual): self
  222.     {
  223.         $this->manual $manual;
  224.         return $this;
  225.     }
  226.     public function getPrivate(): ?bool
  227.     {
  228.         return $this->private;
  229.     }
  230.     public function setPrivate(bool $private): self
  231.     {
  232.         $this->private $private;
  233.         return $this;
  234.     }
  235.     public function getSchedule(): ?\DateTimeInterface
  236.     {
  237.         return $this->schedule;
  238.     }
  239.     public function setSchedule(\DateTimeInterface $schedule): self
  240.     {
  241.         $this->schedule $schedule;
  242.         return $this;
  243.     }
  244.     public function getScheduleDate(): ?\DateTimeInterface
  245.     {
  246.         return $this->schedule_date;
  247.     }
  248.     public function setScheduleDate(?\DateTimeInterface $schedule_date): self
  249.     {
  250.         $this->schedule_date $schedule_date;
  251.         return $this;
  252.     }
  253.     public function getFrequency(): ?string
  254.     {
  255.         return $this->frequency;
  256.     }
  257.     public function setFrequency(?string $frequency): self
  258.     {
  259.         $this->frequency $frequency;
  260.         return $this;
  261.     }
  262.     public function getFrequencyData(): ?string
  263.     {
  264.         return $this->frequency_data;
  265.     }
  266.     public function setFrequencyData(?string $frequency_data): self
  267.     {
  268.         $this->frequency_data $frequency_data;
  269.         return $this;
  270.     }
  271.     public function getArticlesCount(): ?int
  272.     {
  273.         return $this->articles_count;
  274.     }
  275.     public function setArticlesCount(?int $articles_count): self
  276.     {
  277.         $this->articles_count $articles_count;
  278.         return $this;
  279.     }
  280.     public function getMaxArticleAge(): ?int
  281.     {
  282.         return $this->max_article_age;
  283.     }
  284.     public function setMaxArticleAge(?int $max_article_age): self
  285.     {
  286.         $this->max_article_age $max_article_age;
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return mixed
  291.      */
  292.     public function getIsDefault()
  293.     {
  294.         return $this->is_default;
  295.     }
  296.     /**
  297.      * @param mixed $is_default
  298.      *
  299.      * @return Newsletter
  300.      */
  301.     public function setIsDefault($is_default)
  302.     {
  303.         $this->is_default $is_default;
  304.         return $this;
  305.     }
  306.     /**
  307.      * @return Collection|NewsletterArticle[]
  308.      */
  309.     public function getArticles(): Collection
  310.     {
  311.         return $this->articles;
  312.     }
  313.     public function addArticle(NewsletterArticle $article): self
  314.     {
  315.         if (!$this->articles->contains($article)) {
  316.             $this->articles[] = $article;
  317.             $article->setNewsletter($this);
  318.         }
  319.         return $this;
  320.     }
  321.     public function removeArticle(NewsletterArticle $article): self
  322.     {
  323.         if ($this->articles->contains($article)) {
  324.             $this->articles->removeElement($article);
  325.             // set the owning side to null (unless already changed)
  326.             if ($article->getNewsletter() === $this) {
  327.                 $article->setNewsletter(null);
  328.             }
  329.         }
  330.         return $this;
  331.     }
  332.     /**
  333.      * @return Collection|NewsletterCategory[]
  334.      */
  335.     public function getCategories(): Collection
  336.     {
  337.         return $this->categories;
  338.     }
  339.     public function addCategory(NewsletterCategory $category): self
  340.     {
  341.         if (!$this->categories->contains($category)) {
  342.             $this->categories[] = $category;
  343.             $category->setNewsletter($this);
  344.         }
  345.         return $this;
  346.     }
  347.     public function removeCategory(NewsletterCategory $category): self
  348.     {
  349.         if ($this->categories->contains($category)) {
  350.             $this->categories->removeElement($category);
  351.             // set the owning side to null (unless already changed)
  352.             if ($category->getNewsletter() === $this) {
  353.                 $category->setNewsletter(null);
  354.             }
  355.         }
  356.         return $this;
  357.     }
  358.     /**
  359.      * @return Collection|AdvertisingBanner[]
  360.      */
  361.     public function getAdvertisingBanners(): Collection
  362.     {
  363.         return $this->advertisingBanners;
  364.     }
  365.     public function addAdvertisingBanner(AdvertisingBanner $advertisingBanner): self
  366.     {
  367.         if (!$this->advertisingBanners->contains($advertisingBanner)) {
  368.             $this->advertisingBanners[] = $advertisingBanner;
  369.             $advertisingBanner->setNewsletter($this);
  370.         }
  371.         return $this;
  372.     }
  373.     public function removeAdvertisingBanner(AdvertisingBanner $advertisingBanner): self
  374.     {
  375.         if ($this->advertisingBanners->contains($advertisingBanner)) {
  376.             $this->advertisingBanners->removeElement($advertisingBanner);
  377.             // set the owning side to null (unless already changed)
  378.             if ($advertisingBanner->getNewsletter() === $this) {
  379.                 $advertisingBanner->setNewsletter(null);
  380.             }
  381.         }
  382.         return $this;
  383.     }
  384.     /**
  385.      * @return Collection|AdvertisingBanner[]
  386.      */
  387.     public function getAdvertisingBannerContainers(): Collection
  388.     {
  389.         return $this->advertisingBannerContainers;
  390.     }
  391.     public function addAdvertisingBannerContainer(AdvertisingBanner $advertisingBannerContainer): self
  392.     {
  393.         if (!$this->advertisingBannerContainers->contains($advertisingBannerContainer)) {
  394.             $this->advertisingBannerContainers[] = $advertisingBannerContainer;
  395.             $advertisingBannerContainer->setTargetNewsletter($this);
  396.         }
  397.         return $this;
  398.     }
  399.     public function removeAdvertisingBannerContainer(AdvertisingBanner $advertisingBannerContainer): self
  400.     {
  401.         if ($this->advertisingBannerContainers->contains($advertisingBannerContainer)) {
  402.             $this->advertisingBannerContainers->removeElement($advertisingBannerContainer);
  403.             // set the owning side to null (unless already changed)
  404.             if ($advertisingBannerContainer->getTargetNewsletter() === $this) {
  405.                 $advertisingBannerContainer->setTargetNewsletter(null);
  406.             }
  407.         }
  408.         return $this;
  409.     }
  410.     /**
  411.      * @ORM\ManyToOne(targetEntity="App\Entity\Article", inversedBy="newsletter_highlights")
  412.      */
  413.     private $highlighted_article;
  414.     /**
  415.      * @return mixed
  416.      */
  417.     public function getHighlightedArticle()
  418.     {
  419.         return $this->highlighted_article;
  420.     }
  421.     /**
  422.      * @param mixed $highlighted_article
  423.      *
  424.      * @return Newsletter
  425.      */
  426.     public function setHighlightedArticle($highlighted_article)
  427.     {
  428.         $this->highlighted_article $highlighted_article;
  429.         return $this;
  430.     }
  431.     public function hasSender()
  432.     {
  433.         return $this->sender_email || $this->sender_name;
  434.     }
  435.     public function setSender($email$name)
  436.     {
  437.         $this->sender_email $email;
  438.         $this->sender_name $name;
  439.         return $this;
  440.     }
  441.     public function getSender()
  442.     {
  443.         return [
  444.             'email' => $this->sender_email,
  445.             'name' => $this->sender_name,
  446.         ];
  447.     }
  448. }