feat: admin editable email templates
addresses #869eg7ptr
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Config\EmailTextKey;
|
||||
use App\Entity\Traits\BlameableEntity;
|
||||
use App\Entity\Traits\TimestampableEntity;
|
||||
use App\Repository\EmailTextRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* An admin's override of the wording of one transactional mail.
|
||||
*
|
||||
* A row exists only once a mail has been edited; without one the defaults from
|
||||
* App\Config\EmailTextCatalog apply. That is also why there is no soft delete here -
|
||||
* removing the row is exactly "reset to the delivered wording".
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: EmailTextRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'uniq_email_text_template_key', columns: ['template_key'])]
|
||||
class EmailText implements BlameableEntityInterface, TimestampableEntityInterface
|
||||
{
|
||||
use BlameableEntity;
|
||||
use TimestampableEntity;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private string $templateKey;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Assert\NotBlank(message: 'Bitte gib einen Betreff an')]
|
||||
private ?string $subject = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $headline = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
#[Assert\NotBlank(message: 'Bitte gib einen Text an')]
|
||||
private ?string $body = null;
|
||||
|
||||
public function __construct(EmailTextKey $key)
|
||||
{
|
||||
$this->templateKey = $key->value;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTemplateKey(): string
|
||||
{
|
||||
return $this->templateKey;
|
||||
}
|
||||
|
||||
public function getKey(): EmailTextKey
|
||||
{
|
||||
return EmailTextKey::from($this->templateKey);
|
||||
}
|
||||
|
||||
public function getSubject(): ?string
|
||||
{
|
||||
return $this->subject;
|
||||
}
|
||||
|
||||
public function setSubject(?string $subject): static
|
||||
{
|
||||
$this->subject = $subject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHeadline(): ?string
|
||||
{
|
||||
return $this->headline;
|
||||
}
|
||||
|
||||
public function setHeadline(?string $headline): static
|
||||
{
|
||||
$this->headline = $headline;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBody(): ?string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
public function setBody(?string $body): static
|
||||
{
|
||||
$this->body = $body;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user