<?php
namespace App\Entity;
use App\Repository\NewsletterRepository;
use App\Traits\DateTrait;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=NewsletterRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Newsletter
{
use DateTrait;
public const STATUS_DRAFT = "draft";
public const STATUS_PENDING = "pending";
public const STATUS_PROGRAMMED = "programmed";
public const STATUS_PROCESSING = "processing";
public const STATUS_STOPPED = "stopped";
public const STATUS_SENT = "sent";
public const CONTENT_TAGS = [
// pour gérer [AVAILABLE_POINTS]
'recipient',
'contact_first_name',
'contact_last_name',
'contact_full_name',
'contact_email',
'contact_phone',
'contact_address',
'current_date',
'current_day',
'current_month',
'current_year'
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = NULL;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $name = NULL;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description = NULL;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $subject = NULL;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $contents = NULL;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTimeInterface $requestDateTimeSend = NULL;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTimeInterface $sendAt = NULL;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
private bool $sendNow = FALSE;
/**
* @ORM\Column(type="string", length=50, options={"default":self::STATUS_PENDING})
*/
private string $status = self::STATUS_PENDING;
/**
* @ORM\ManyToOne(targetEntity=ContactList::class, inversedBy="newsletters")
* @ORM\JoinColumn(nullable=false)
*/
private ?ContactList $contactList;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $templateType = NULL;
/**
* @ORM\Column(type="string", length=64)
*/
private ?string $templateId = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $mailwizzId = NULL;
/**
* @ORM\Column(type="boolean", options={"default":false})
*/
private bool $isSendToMailwizz = FALSE;
/**
* @ORM\Column(type="simple_array", nullable=true)
*/
private ?array $emails;
/**
* @ORM\Column(type="text")
*/
private ?string $htmlPath = NULL;
/**
* ******************************************************
* ********************* START CUSTOM *******************
* ******************************************************
*/
public function isEditable(): bool
{
return $this->status === self::STATUS_DRAFT || $this->status === self::STATUS_PENDING;
}
public function isProcessing(): bool
{
return $this->status === self::STATUS_PROCESSING;
}
public function isStopped(): bool
{
return $this->status === self::STATUS_STOPPED;
}
/**
* ******************************************************
* ********************** END CUSTOM ********************
* ******************************************************
*/
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSubject(): ?string
{
return $this->subject;
}
public function setSubject(string $subject): self
{
$this->subject = $subject;
return $this;
}
public function getDescription()
{
return $this->description;
}
public function setDescription($description): self
{
$this->description = $description;
return $this;
}
public function getContents(): ?string
{
return $this->contents;
}
public function setContents(?string $contents): self
{
$this->contents = $contents;
return $this;
}
public function getRequestDateTimeSend(): ?DateTimeInterface
{
return $this->requestDateTimeSend;
}
public function setRequestDateTimeSend(?DateTimeInterface $requestDateTimeSend): self
{
$this->requestDateTimeSend = $requestDateTimeSend;
return $this;
}
public function getSendAt(): ?DateTimeInterface
{
return $this->sendAt;
}
public function setSendAt(?DateTimeInterface $sendAt): self
{
$this->sendAt = $sendAt;
return $this;
}
public function getSendNow(): ?bool
{
return $this->sendNow;
}
public function setSendNow(bool $sendNow): self
{
$this->sendNow = $sendNow;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getContactList(): ?ContactList
{
return $this->contactList;
}
public function setContactList(?ContactList $contactList): self
{
$this->contactList = $contactList;
return $this;
}
public function getTemplateType(): ?string
{
return $this->templateType;
}
public function setTemplateType(string $templateType): self
{
$this->templateType = $templateType;
return $this;
}
public function getMailwizzId(): ?string
{
return $this->mailwizzId;
}
public function setMailwizzId(?string $mailwizzId): self
{
$this->mailwizzId = $mailwizzId;
return $this;
}
public function isIsSendToMailwizz(): ?bool
{
return $this->isSendToMailwizz;
}
public function setIsSendToMailwizz(bool $isSendToMailwizz): self
{
$this->isSendToMailwizz = $isSendToMailwizz;
return $this;
}
public function getEmails(): ?array
{
return $this->emails;
}
public function setEmails(?array $emails): self
{
$this->emails = $emails;
return $this;
}
public function getHtmlPath(): ?string
{
return $this->htmlPath;
}
public function setHtmlPath(string $htmlPath): self
{
$this->htmlPath = $htmlPath;
return $this;
}
public function getTemplateId(): ?string
{
return $this->templateId;
}
public function setTemplateId(string $templateId): self
{
$this->templateId = $templateId;
return $this;
}
}