Fixed exception when attachment file is not openable

This commit is contained in:
Jan Böhmer 2023-03-15 22:15:30 +01:00
parent 47fce4e914
commit ed514a01bb

View file

@ -164,23 +164,23 @@ class EntityURLGenerator
throw new EntityNotSupportedException('The given entity is not supported yet!'); throw new EntityNotSupportedException('The given entity is not supported yet!');
} }
public function viewURL(Attachment $entity): ?string public function viewURL(Attachment $entity): string
{ {
if ($entity->isExternal()) { //For external attachments, return the link to external path if ($entity->isExternal()) { //For external attachments, return the link to external path
return $entity->getURL(); return $entity->getURL();
} }
//return $this->urlGenerator->generate('attachment_view', ['id' => $entity->getID()]); //return $this->urlGenerator->generate('attachment_view', ['id' => $entity->getID()]);
return $this->attachmentURLGenerator->getViewURL($entity); return $this->attachmentURLGenerator->getViewURL($entity) ?? '';
} }
public function downloadURL($entity): ?string public function downloadURL($entity): string
{ {
if ($entity instanceof Attachment) { if ($entity instanceof Attachment) {
if ($entity->isExternal()) { //For external attachments, return the link to external path if ($entity->isExternal()) { //For external attachments, return the link to external path
return $entity->getURL(); return $entity->getURL();
} }
return $this->attachmentURLGenerator->getDownloadURL($entity); return $this->attachmentURLGenerator->getDownloadURL($entity) ?? '';
} }
//Otherwise throw an error //Otherwise throw an error