downloadDirectory = $downloadDirectory; } /** * {@inheritdoc} * * @throws AttachmentNotFoundException */ public function handle(GetAttachment $query): Attachment { $attachment = $this->getAttachment($query->getAttachmentId()); $path = $this->downloadDirectory . $attachment->file; if (!file_exists($path)) { throw new AttachmentNotFoundException(sprintf('Attachment file was not found at %s', $path)); } return new Attachment( $path, $attachment->file_name ); } }