src/Entity/EmailMessage.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EmailMessageRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassEmailMessageRepository::class)]
  8. #[ORM\Table(name'email_messages')]
  9. class EmailMessage extends BaseEntity
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(targetEntitySales::class, inversedBy'emailMessages')]
  16.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  17.     private ?Sales $sale null;
  18.     #[ORM\ManyToOne(targetEntityUser::class)]
  19.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  20.     private ?User $sentBy null;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $senderEmail null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $senderName null;
  25.     #[ORM\Column(length255)]
  26.     private string $subject;
  27.     #[ORM\Column(type'text')]
  28.     private string $body;
  29.     #[ORM\Column(type'datetime_immutable')]
  30.     private \DateTimeImmutable $sentAt;
  31.     #[ORM\Column(length64uniquetrue)]
  32.     private string $messageToken;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $externalMessageId null;
  35.     /**
  36.      * @var Collection<int, EmailRecipient>
  37.      */
  38.     #[ORM\OneToMany(mappedBy'emailMessage'targetEntityEmailRecipient::class, cascade: ['persist'], orphanRemovaltrue)]
  39.     private Collection $recipients;
  40.     public function __construct()
  41.     {
  42.         $this->recipients = new ArrayCollection();
  43.         $this->sentAt = new \DateTimeImmutable();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getSale(): ?Sales
  50.     {
  51.         return $this->sale;
  52.     }
  53.     public function setSale(?Sales $sale): self
  54.     {
  55.         $this->sale $sale;
  56.         return $this;
  57.     }
  58.     public function getSentBy(): ?User
  59.     {
  60.         return $this->sentBy;
  61.     }
  62.     public function setSentBy(?User $sentBy): self
  63.     {
  64.         $this->sentBy $sentBy;
  65.         return $this;
  66.     }
  67.     public function getSenderEmail(): ?string
  68.     {
  69.         return $this->senderEmail;
  70.     }
  71.     public function setSenderEmail(?string $senderEmail): self
  72.     {
  73.         $this->senderEmail $senderEmail;
  74.         return $this;
  75.     }
  76.     public function getSenderName(): ?string
  77.     {
  78.         return $this->senderName;
  79.     }
  80.     public function setSenderName(?string $senderName): self
  81.     {
  82.         $this->senderName $senderName;
  83.         return $this;
  84.     }
  85.     public function getSubject(): string
  86.     {
  87.         return $this->subject;
  88.     }
  89.     public function setSubject(string $subject): self
  90.     {
  91.         $this->subject $subject;
  92.         return $this;
  93.     }
  94.     public function getBody(): string
  95.     {
  96.         return $this->body;
  97.     }
  98.     public function setBody(string $body): self
  99.     {
  100.         $this->body $body;
  101.         return $this;
  102.     }
  103.     public function getSentAt(): \DateTimeImmutable
  104.     {
  105.         return $this->sentAt;
  106.     }
  107.     public function setSentAt(\DateTimeImmutable $sentAt): self
  108.     {
  109.         $this->sentAt $sentAt;
  110.         return $this;
  111.     }
  112.     public function getMessageToken(): string
  113.     {
  114.         return $this->messageToken;
  115.     }
  116.     public function setMessageToken(string $messageToken): self
  117.     {
  118.         $this->messageToken $messageToken;
  119.         return $this;
  120.     }
  121.     public function getExternalMessageId(): ?string
  122.     {
  123.         return $this->externalMessageId;
  124.     }
  125.     public function setExternalMessageId(?string $externalMessageId): self
  126.     {
  127.         $this->externalMessageId $externalMessageId;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection<int, EmailRecipient>
  132.      */
  133.     public function getRecipients(): Collection
  134.     {
  135.         return $this->recipients;
  136.     }
  137.     public function addRecipient(EmailRecipient $recipient): self
  138.     {
  139.         if (!$this->recipients->contains($recipient)) {
  140.             $this->recipients->add($recipient);
  141.             $recipient->setEmailMessage($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeRecipient(EmailRecipient $recipient): self
  146.     {
  147.         if ($this->recipients->removeElement($recipient)) {
  148.             if ($recipient->getEmailMessage() === $this) {
  149.                 $recipient->setEmailMessage(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154. }