mail-rss/src/Entity/Mailing.php

91 lines
1.9 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\MailingRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use App\Doctrine\Timestampable;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=MailingRepository::class)
* @ORM\Table("mailing", options={"collate"="utf8mb4_unicode_ci", "charset"="utf8mb4"})
* @ORM\HasLifecycleCallbacks
*/
class Mailing
{
use Timestampable;
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
* @ORM\Column(type="uuid")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $label;
/**
* @ORM\OneToMany(targetEntity=Mail::class, mappedBy="mailing", orphanRemoval=true, cascade={"all"})
*/
private $mails;
public function __construct()
{
$this->mails = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
/**
* @return Collection|Mail[]
*/
public function getMails(): Collection
{
return $this->mails;
}
public function addMail(Mail $mail): self
{
if (!$this->mails->contains($mail)) {
$this->mails[] = $mail;
$mail->setMailing($this);
}
return $this;
}
public function removeMail(Mail $mail): self
{
if ($this->mails->removeElement($mail)) {
// set the owning side to null (unless already changed)
if ($mail->getMailing() === $this) {
$mail->setMailing(null);
}
}
return $this;
}
}