*/ #[ORM\OneToMany(targetEntity: Upload::class, mappedBy: 'mailingTemplate')] #[ORM\OrderBy(['id' => \SortDirection::Ascending])] private Collection $attachments; public function __construct() { $this->uuid = Uuid::v4(); $this->attachments = new ArrayCollection(); } public function __toString(): string { return (string) $this->name; } public function getId(): ?int { return $this->id; } public function getUuid(): string { return $this->uuid; } public function getName(): ?string { return $this->name; } public function setName(?string $name): static { $this->name = $name; return $this; } public function getSubject(): ?string { return $this->subject; } public function setSubject(?string $subject): static { $this->subject = $subject; return $this; } public function getMessage(): ?string { return $this->message; } public function setMessage(?string $message): static { $this->message = $message; return $this; } /** * @return Collection */ public function getAttachments(): Collection { return $this->attachments; } public function addAttachment(Upload $attachment): static { if (!$this->attachments->contains($attachment)) { $this->attachments->add($attachment); $attachment->setMailingTemplate($this); } return $this; } public function removeAttachment(Upload $attachment): static { if ($this->attachments->removeElement($attachment) && $attachment->getMailingTemplate() === $this) { $attachment->setMailingTemplate(null); } return $this; } public function getAttachmentSize(): int { return array_sum($this->attachments->map(fn (Upload $upload) => (int) $upload->getSize())->toArray()); } }