diff --git a/application/Espo/Core/EntryPoint/EntryPoint.php b/application/Espo/Core/EntryPoint/EntryPoint.php index 20d4686c69..2208bf8457 100644 --- a/application/Espo/Core/EntryPoint/EntryPoint.php +++ b/application/Espo/Core/EntryPoint/EntryPoint.php @@ -29,10 +29,12 @@ namespace Espo\Core\EntryPoint; -use Espo\Core\{ - Api\Request, - Api\Response, -}; +use Espo\Core\Api\Request; +use Espo\Core\Api\Response; +use Espo\Core\Exceptions\BadRequest; +use Espo\Core\Exceptions\Error; +use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Exceptions\NotFound; /** * An entry point to the application by `?entryPoint={entityPointName}` URI. @@ -40,5 +42,11 @@ use Espo\Core\{ */ interface EntryPoint { + /** + * @throws Error + * @throws Forbidden + * @throws BadRequest + * @throws NotFound + */ public function run(Request $request, Response $response): void; } diff --git a/application/Espo/EntryPoints/Download.php b/application/Espo/EntryPoints/Download.php index 75e40906db..7c1975f1d1 100644 --- a/application/Espo/EntryPoints/Download.php +++ b/application/Espo/EntryPoints/Download.php @@ -30,18 +30,16 @@ namespace Espo\EntryPoints; use Espo\Entities\Attachment as AttachmentEntity; - -use Espo\Core\{ - Exceptions\BadRequest, - Exceptions\Forbidden, - Exceptions\NotFoundSilent, - EntryPoint\EntryPoint, - Acl, - ORM\EntityManager, - Api\Request, - Api\Response, - FileStorage\Manager as FileStorageManager, - Utils\Metadata}; +use Espo\Core\Acl; +use Espo\Core\Api\Request; +use Espo\Core\Api\Response; +use Espo\Core\EntryPoint\EntryPoint; +use Espo\Core\Exceptions\BadRequest; +use Espo\Core\Exceptions\Forbidden; +use Espo\Core\Exceptions\NotFoundSilent; +use Espo\Core\FileStorage\Manager as FileStorageManager; +use Espo\Core\ORM\EntityManager; +use Espo\Core\Utils\Metadata; class Download implements EntryPoint { @@ -70,8 +68,8 @@ class Download implements EntryPoint throw new BadRequest(); } - /** @var AttachmentEntity|null $attachment */ - $attachment = $this->entityManager->getEntityById('Attachment', $id); + /** @var ?AttachmentEntity $attachment */ + $attachment = $this->entityManager->getEntityById(AttachmentEntity::ENTITY_TYPE, $id); if (!$attachment) { throw new NotFoundSilent(); @@ -89,7 +87,7 @@ class Download implements EntryPoint $outputFileName = str_replace("\"", "\\\"", $attachment->get('name')); - $type = $attachment->get('type'); + $type = $attachment->getType(); $disposition = 'attachment';