src/Entity/FormPage.php line 19

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Entity;
  3. use App\Validator as AppAssert;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use App\Entity\Embeddable\FormPage\Config;
  7. use Doctrine\Common\Collections\Collection;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use App\Entity\Embeddable\FormPage\ConfigInterface;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[ORM\Entity]
  14. #[Vich\Uploadable]
  15. class FormPage extends Page implements FormPageInterface
  16. {
  17.     #[ORM\OneToMany(targetEntityLead::class, mappedBy'formPage'fetch'EXTRA_LAZY')]
  18.     private $leads;
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private $leadEmailTemplateFilename;
  21.     #[ORM\Column(type'string'length255nullabletrue)]
  22.     private $confirmationTemplateFilename;
  23.     #[Vich\UploadableField(mapping'page_confirmation_template'fileNameProperty'confirmationTemplateFilename')]
  24.     #[Assert\File(maxSize'1024k'mimeTypes: ['text/html'], mimeTypesMessage'Please upload a valid .html')]
  25.     private $confirmationTemplateFile;
  26.     #[Vich\UploadableField(mapping'page_lead_email'fileNameProperty'leadEmailTemplateFilename')]
  27.     private $leadEmailTemplateFile;
  28.     #[ORM\Column(type'json'nullabletrue)]
  29.     private $formConfig = [];
  30.     #[ORM\Embedded(class: '\App\Entity\Embeddable\FormPage\Config')]
  31.     private $config;
  32.     #[ORM\Column(type'json'nullabletrue)]
  33.     private $data = [];
  34.     #[ORM\Column(type'json'nullabletrue)]
  35.     private $queryMapping = [];
  36.     #[ORM\Column(type'text'nullabletrue)]
  37.     #[AppAssert\Twig(message'twig.error')]
  38.     private $confirmBodyEndCode;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     #[AppAssert\Twig(message'twig.error')]
  41.     private $userEmailSubject;
  42.     #[ORM\Column(typeTypes::ARRAY, nullabletrue)]
  43.     private ?array $extraEmailRecipients = [];
  44.     public function __construct()
  45.     {
  46.         $this->leads = new ArrayCollection();
  47.         $this->config = new Config();
  48.     }
  49.     /**
  50.      * {@inheritDoc}
  51.      */
  52.     public function getLeads(): Collection
  53.     {
  54.         return $this->leads;
  55.     }
  56.     public function addLead(LeadInterface $lead): self
  57.     {
  58.         if (!$this->leads->contains($lead)) {
  59.             $this->leads[] = $lead;
  60.             $lead->setFormPage($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeLead(LeadInterface $lead): self
  65.     {
  66.         if ($this->leads->contains($lead)) {
  67.             $this->leads->removeElement($lead);
  68.             // set the owning side to null (unless already changed)
  69.             if ($lead->getFormPage() === $this) {
  70.                 $lead->setFormPage(null);
  71.             }
  72.         }
  73.         return $this;
  74.     }
  75.     public function getConfirmationTemplateFilename(): ?string
  76.     {
  77.         return $this->confirmationTemplateFilename;
  78.     }
  79.     public function setConfirmationTemplateFilename(?string $confirmationTemplateFilename): self
  80.     {
  81.         $this->confirmationTemplateFilename $confirmationTemplateFilename;
  82.         return $this;
  83.     }
  84.     /**
  85.      * {@inheritDoc}
  86.      */
  87.     public function setConfirmationTemplateFile(?File $confirmationTemplateFile null): void
  88.     {
  89.         $this->confirmationTemplateFile $confirmationTemplateFile;
  90.         if (null !== $confirmationTemplateFile) {
  91.             // It is required that at least one field changes if you are using doctrine
  92.             // otherwise the event listeners won't be called and the file is lost
  93.             $this->updatedAt = new \DateTimeImmutable();
  94.         }
  95.     }
  96.     public function getConfirmationTemplateFile(): ?File
  97.     {
  98.         return $this->confirmationTemplateFile;
  99.     }
  100.     public function getLeadEmailTemplateFilename(): ?string
  101.     {
  102.         return $this->leadEmailTemplateFilename;
  103.     }
  104.     public function setLeadEmailTemplateFilename(?string $leadEmailTemplateFilename): self
  105.     {
  106.         $this->leadEmailTemplateFilename $leadEmailTemplateFilename;
  107.         return $this;
  108.     }
  109.     public function getUserEmailSubject(): ?string
  110.     {
  111.         return $this->userEmailSubject;
  112.     }
  113.     public function setUserEmailSubject(?string $userEmailSubject): self
  114.     {
  115.         $this->userEmailSubject $userEmailSubject;
  116.         return $this;
  117.     }
  118.     /**
  119.      * {@inheritDoc}
  120.      */
  121.     public function setLeadEmailTemplateFile(?File $leadEmailTemplateFile null): void
  122.     {
  123.         $this->leadEmailTemplateFile $leadEmailTemplateFile;
  124.         if (null !== $leadEmailTemplateFile) {
  125.             // It is required that at least one field changes if you are using doctrine
  126.             // otherwise the event listeners won't be called and the file is lost
  127.             $this->updatedAt = new \DateTimeImmutable();
  128.         }
  129.     }
  130.     public function getLeadEmailTemplateFile(): ?File
  131.     {
  132.         return $this->leadEmailTemplateFile;
  133.     }
  134.     public function getFormConfig(): ?array
  135.     {
  136.         return $this->formConfig;
  137.     }
  138.     public function setFormConfig(?array $formConfig): self
  139.     {
  140.         $this->formConfig $formConfig;
  141.         return $this;
  142.     }
  143.     public function getConfig(): ?ConfigInterface
  144.     {
  145.         return $this->config;
  146.     }
  147.     public function setConfig(?ConfigInterface $config): self
  148.     {
  149.         $this->config $config;
  150.         return $this;
  151.     }
  152.     public function getQueryMapping(): ?array
  153.     {
  154.         return $this->queryMapping;
  155.     }
  156.     public function setQueryMapping(?array $queryMapping): self
  157.     {
  158.         $this->queryMapping $queryMapping;
  159.         return $this;
  160.     }
  161.     public function getData(): ?array
  162.     {
  163.         return $this->data;
  164.     }
  165.     public function setData(?array $data): self
  166.     {
  167.         $this->data $data;
  168.         return $this;
  169.     }
  170.     public function getConfirmBodyEndCode(): ?string
  171.     {
  172.         return $this->confirmBodyEndCode;
  173.     }
  174.     public function setConfirmBodyEndCode(?string $confirmBodyEndCode): self
  175.     {
  176.         $this->confirmBodyEndCode $confirmBodyEndCode;
  177.         return $this;
  178.     }
  179.     public function getExtraEmailRecipients(): ?array
  180.     {
  181.         return $this->extraEmailRecipients;
  182.     }
  183.     public function setExtraEmailRecipients(?array $extraEmailRecipients): self
  184.     {
  185.         $this->extraEmailRecipients $extraEmailRecipients;
  186.         return $this;
  187.     }
  188. }