src/Flexy/Apps/NewsletterBundle/Entity/NewsletterCompaign.php line 15
<?php
namespace App\Flexy\Apps\NewsletterBundle\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Flexy\FrontBundle\Entity\Page;
use App\Repository\Flexy\Apps\NewsletterBundle\Entity\NewsletterCompaignRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NewsletterCompaignRepository::class)]
#[ApiResource]
class NewsletterCompaign
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\Column(length: 255)]
private ?string $entity = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?Page $mailPage = null;
#[ORM\OneToMany(mappedBy: 'newsletterCompaign', targetEntity: NewsletterCompaignLaunch::class, orphanRemoval: true)]
private Collection $newsletterCompaignLaunches;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->newsletterCompaignLaunches = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getEntity(): ?string
{
return $this->entity;
}
public function setEntity(string $entity): static
{
$this->entity = $entity;
return $this;
}
public function getMailPage(): ?Page
{
return $this->mailPage;
}
public function setMailPage(?Page $mailPage): static
{
$this->mailPage = $mailPage;
return $this;
}
/**
* @return Collection<int, NewsletterCompaignLaunch>
*/
public function getNewsletterCompaignLaunches(): Collection
{
return $this->newsletterCompaignLaunches;
}
public function addNewsletterCompaignLaunch(NewsletterCompaignLaunch $newsletterCompaignLaunch): static
{
if (!$this->newsletterCompaignLaunches->contains($newsletterCompaignLaunch)) {
$this->newsletterCompaignLaunches->add($newsletterCompaignLaunch);
$newsletterCompaignLaunch->setNewsletterCompaign($this);
}
return $this;
}
public function removeNewsletterCompaignLaunch(NewsletterCompaignLaunch $newsletterCompaignLaunch): static
{
if ($this->newsletterCompaignLaunches->removeElement($newsletterCompaignLaunch)) {
// set the owning side to null (unless already changed)
if ($newsletterCompaignLaunch->getNewsletterCompaign() === $this) {
$newsletterCompaignLaunch->setNewsletterCompaign(null);
}
}
return $this;
}
}