*/ class Document extends Record { /** * @return \Espo\ORM\Collection * @throws NotFound * @throws \Espo\Core\Exceptions\Forbidden */ public function getAttachmentList(string $id) { $entity = $this->getEntity($id); if (!$entity) { throw new NotFound(); } $fileId = $entity->get('fileId'); if (!$fileId) { throw new NotFound(); } $file = $this->getEntityManager()->getEntity('Attachment', $fileId); if (!$file) { throw new NotFound(); } $attachment = $this->getAttachmentRepository()->getCopiedAttachment($file, 'Attachment'); /** @var \Espo\ORM\EntityCollection $attachmentList */ $attachmentList = $this->entityManager ->getCollectionFactory() ->create('Attachment'); $attachmentList[] = $attachment; return $attachmentList; } private function getAttachmentRepository(): AttachmentRepository { /** @var AttachmentRepository */ return $this->entityManager->getRepository(Attachment::ENTITY_TYPE); } }