src/Entity/EmailTemplate.php line 19
<?php/** @author Guerby Duval <info@tranzaksyon.com>* @link https://tranzaksyon.com* @copyright You are not allowed to remove this author "Guerby Duval <info@tranzaksyon.com>", the link "https://tranzaksyon.com" neither this copyright.*/namespace App\Entity;use App\Repository\EmailTemplateRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints\Callback;use Symfony\Component\Validator\Constraints\NotBlank;use Symfony\Component\Validator\ConstraintViolation;use Symfony\Component\Validator\Context\ExecutionContextInterface;#[ORM\Entity(repositoryClass: EmailTemplateRepository::class)]class EmailTemplate{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255, nullable: true)]private ?string $title = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $template = null;#[ORM\Column(nullable: true)]private ?bool $html = null;#[ORM\Column(length: 20, nullable: true)]private ?string $invoiceType = null;#[ORM\ManyToOne(inversedBy: 'emailTemplates')]#[ORM\JoinColumn(nullable: true)]private ?EmailConfiguration $configuration = null;#[ORM\Column(nullable: true)]private ?bool $isDefault = null;#[ORM\Column(nullable: true)]private ?bool $useDefault = null;public function getId(): ?int{return $this->id;}public function getTitle(): ?string{return $this->title;}public function setTitle(?string $title): self{$this->title = $title;return $this;}public function getTemplate(): ?string{return $this->template;}public function setTemplate(?string $template): self{$this->template = $template;return $this;}public function isHtml(): ?bool{return $this->html;}public function setHtml(?bool $html): self{$this->html = $html;return $this;}public function getInvoiceType(): ?string{return $this->invoiceType;}public function setInvoiceType(string $invoiceType): self{$this->invoiceType = $invoiceType;return $this;}public function getConfiguration(): ?EmailConfiguration{return $this->configuration;}public function setConfiguration(?EmailConfiguration $configuration): self{$this->configuration = $configuration;return $this;}public function isIsDefault(): ?bool{return $this->isDefault;}public function setIsDefault(?bool $isDefault): self{$this->isDefault = $isDefault;return $this;}public function isUseDefault(): ?bool{return $this->useDefault;}public function setUseDefault(?bool $useDefault): self{$this->useDefault = $useDefault;return $this;}#[Callback(payload: 'title')]public function isTitleValid(ExecutionContextInterface $context){if (!$this->isUseDefault()) {$validations = $context->getValidator()->validate($this->getTitle(), [new NotBlank()]);/** @var ConstraintViolation $validation */foreach ($validations as $validation) {$context->buildViolation($validation->getMessage())->atPath('title')->addViolation();}}}#[Callback(payload: 'template')]public function isTemplateValid(ExecutionContextInterface $context){if (!$this->isUseDefault()) {$validations = $context->getValidator()->validate($this->getTemplate(), [new NotBlank()]);/** @var ConstraintViolation $validation */foreach ($validations as $validation) {$context->buildViolation($validation->getMessage())->atPath('template')->addViolation();}}}}