src/Entity/Email.php line 18

  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Entity\Mapped\Entity;
  5. use App\Repository\EmailRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(
  9.     repositoryClassEmailRepository::class
  10. )]
  11. #[ORM\Table(
  12.     name'email'
  13. )]
  14. class Email extends Entity
  15. {
  16.     #[ORM\Column(
  17.         name'recipent',
  18.         type'string'
  19.     )]
  20.     private string $recipient;
  21.     #[ORM\Column(
  22.         name'title',
  23.         type'string',
  24.         length191
  25.     )]
  26.     private string $title;
  27.     #[ORM\Column(
  28.         name'content',
  29.         type'text'
  30.     )]
  31.     private string $content;
  32.     #[ORM\OneToMany(
  33.         mappedBy'email',
  34.         targetEntityEmailAttachment::class,
  35.         cascade: ['persist'],
  36.         fetch'EAGER',
  37.         orphanRemovaltrue
  38.     )]
  39.     private object $attachments;
  40.     public function __construct()
  41.     {
  42.         $this->attachments = new ArrayCollection();
  43.     }
  44.     public function getRecipient(): string
  45.     {
  46.         return $this->recipient;
  47.     }
  48.     public function setRecipient(string $recipient): self
  49.     {
  50.         $this->recipient $recipient;
  51.         return $this;
  52.     }
  53.     public function getTitle(): string
  54.     {
  55.         return $this->title;
  56.     }
  57.     public function setTitle(string $title): self
  58.     {
  59.         $this->title $title;
  60.         return $this;
  61.     }
  62.     public function getContent(): string
  63.     {
  64.         return $this->content;
  65.     }
  66.     public function setContent(string $content): self
  67.     {
  68.         $this->content $content;
  69.         return $this;
  70.     }
  71.     public function getAttachments(): object
  72.     {
  73.         return $this->attachments;
  74.     }
  75.     public function addAttachment(EmailAttachment $emailAttachment): void
  76.     {
  77.         if ($this->attachments->contains($emailAttachment)) {
  78.             return;
  79.         }
  80.         $emailAttachment->setEmail($this);
  81.         $this->attachments[] = $emailAttachment;
  82.     }
  83.     public function removeAttachment(EmailAttachment $emailAttachment): void
  84.     {
  85.         if (!$this->attachments->contains($emailAttachment)) {
  86.             return;
  87.         }
  88.         $emailAttachment->setEmail(null);
  89.         $this->attachments->removeElement($emailAttachment);
  90.     }
  91. }