158 lines
3.2 KiB
PHP
158 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\MailRepository;
|
|
use App\Doctrine\Timestampable;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
/**
|
|
* @ORM\Entity(repositoryClass=MailRepository::class)
|
|
* @ORM\HasLifecycleCallbacks
|
|
*/
|
|
class Mail
|
|
{
|
|
use Timestampable;
|
|
|
|
/**
|
|
* @ORM\Id()
|
|
* @ORM\GeneratedValue(strategy="CUSTOM")
|
|
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
|
|
* @ORM\Column(type="uuid")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity=Mailing::class, inversedBy="mails")
|
|
* @ORM\JoinColumn(nullable=false)
|
|
*/
|
|
private $mailing;
|
|
|
|
/**
|
|
* @ORM\Column(type="string", length=255)
|
|
*/
|
|
private $subject;
|
|
|
|
/**
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
private $date;
|
|
|
|
/**
|
|
* @ORM\Column(type="text", nullable=true)
|
|
*/
|
|
private $htmlContent;
|
|
|
|
/**
|
|
* @ORM\Column(type="text", nullable=true)
|
|
*/
|
|
private $textContent;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity=MailAttachment::class, mappedBy="mail", orphanRemoval=true)
|
|
*/
|
|
private $mailAttachments;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->mailAttachments = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?string
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getMailing(): ?Mailing
|
|
{
|
|
return $this->mailing;
|
|
}
|
|
|
|
public function setMailing(?Mailing $mailing): self
|
|
{
|
|
$this->mailing = $mailing;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getSubject(): ?string
|
|
{
|
|
return $this->subject;
|
|
}
|
|
|
|
public function setSubject(string $subject): self
|
|
{
|
|
$this->subject = $subject;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->date;
|
|
}
|
|
|
|
public function setDate(\DateTimeInterface $date): self
|
|
{
|
|
$this->date = $date;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getHtmlContent(): ?string
|
|
{
|
|
return $this->htmlContent;
|
|
}
|
|
|
|
public function setHtmlContent(?string $htmlContent): self
|
|
{
|
|
$this->htmlContent = $htmlContent;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTextContent(): ?string
|
|
{
|
|
return $this->textContent;
|
|
}
|
|
|
|
public function setTextContent(?string $textContent): self
|
|
{
|
|
$this->textContent = $textContent;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|MailAttachment[]
|
|
*/
|
|
public function getMailAttachments(): Collection
|
|
{
|
|
return $this->mailAttachments;
|
|
}
|
|
|
|
public function addMailAttachment(MailAttachment $mailAttachment): self
|
|
{
|
|
if (!$this->mailAttachments->contains($mailAttachment)) {
|
|
$this->mailAttachments[] = $mailAttachment;
|
|
$mailAttachment->setMail($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeMailAttachment(MailAttachment $mailAttachment): self
|
|
{
|
|
if ($this->mailAttachments->removeElement($mailAttachment)) {
|
|
// set the owning side to null (unless already changed)
|
|
if ($mailAttachment->getMail() === $this) {
|
|
$mailAttachment->setMail(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|