Commit 7b4c0021 authored by Fabian Galinski's avatar Fabian Galinski 😾
Browse files

[FEATURE] Adds more functions to the mail template service. AddMarkers and better file management

parent c5f09584
......@@ -35,6 +35,7 @@ use Swift_Attachment;
use Swift_OutputByteStream;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
......@@ -353,6 +354,15 @@ class MailTemplateService {
return $this;
}
/**
* @param array $markers
* @return MailTemplateService
*/
public function addMarkers(array $markers): MailTemplateService {
$this->setMarkers(\array_merge($this->markers, $markers));
return $this;
}
/**
* @param array $markers
* @return MailTemplateService
......@@ -409,24 +419,34 @@ class MailTemplateService {
/**
* Adds a file resource as attachment
*
* @param FileReference $file
* @param FileReference $fileReference
* @param File $file
*
* @return MailTemplateService
* @throws \TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
*/
public function addFileResourceAttachment(FileReference $file): MailTemplateService {
$originalResource = $file->getOriginalResource();
if (!$originalResource) {
return $this;
}
$originalFile = $originalResource->getOriginalFile();
if (!$originalFile) {
return $this;
public function addFileResourceAttachment(
FileReference $fileReference = NULL, File $file = NULL
): MailTemplateService {
if (!$file) {
if (!$fileReference) {
return $this;
}
$originalResource = $fileReference->getOriginalResource();
if (!$originalResource) {
return $this;
}
$file = $originalResource->getOriginalFile();
if (!$file) {
return $this;
}
}
$coreFileReferenceMailFile = $this->resourceFactory->createFileReferenceObject(
[
'uid_local' => $originalFile->getUid(),
'uid_local' => $file->getUid(),
'table_local' => 'sys_file',
'uid' => uniqid('NEW_MAIL', TRUE)
]
......
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