Commit 30a00fdb authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[BUGFIX] Fix the attachment reference generation

parent 0c36b0b7
......@@ -37,6 +37,7 @@ use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
......@@ -640,13 +641,20 @@ class MailTemplateService {
*/
public function addFileResourceAttachment($file) {
if ($file instanceof FileReference) {
$this->markers[] = $file;
$file = $file->getOriginalResource()->getOriginalFile();
} elseif ($file instanceof FileInterface) {
$fileReference = $this->objectManager->get(FileReference::class);
$fileReference->setOriginalResource($file);
$this->markers[] = $fileReference;
}
$fileReference = $this->objectManager->get(FileReference::class);
$resourceFactory = $this->objectManager->get(ResourceFactory::class);
$falFileReference = $resourceFactory->createFileReferenceObject(
[
'uid_local' => $file->getUid(),
'uid_foreign' => uniqid('NEW_', TRUE),
'uid' => uniqid('NEW_', TRUE),
'crop' => NULL,
]
);
$fileReference->setOriginalResource($falFileReference);
$this->markers[] = $fileReference;
$this->addAttachment($file->getContents(), $file->getName(), $file->getMimeType());
return $this;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment