[TASK] Improve mail template handling

This commit is contained in:
Philipp Dieter 2020-11-12 00:15:26 +01:00
parent b7f93518d0
commit 504386c717
4 changed files with 23 additions and 5 deletions

View File

@ -19,6 +19,7 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Service\ImageService; use TYPO3\CMS\Extbase\Service\ImageService;
use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Fluid\View\TemplatePaths; use TYPO3\CMS\Fluid\View\TemplatePaths;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
/** /**
* *
@ -49,15 +50,31 @@ class MailUtility
$templateRootPaths = $templatePaths->getTemplateRootPaths(); $templateRootPaths = $templatePaths->getTemplateRootPaths();
} }
if (!$templateNameHtml) { if (!$templateNameHtml) {
$templateNameHtml = 'Mailing/DefaultHtml'; $templateNameHtml = 'Mails/DefaultHtml';
} }
if (!$templateNameText) { if (!$templateNameText) {
$templateNameText = 'Mailing/DefaultText'; $templateNameText = 'Mails/DefaultText';
} }
$htmlView = GeneralUtility::makeInstance(StandaloneView::class); $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(
ConfigurationManagerInterface::class
);
$typoScript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
$settings =
(array)$typoScript['module.']['tx_templatesaide.']['settings.'];
$settings = GeneralUtility::removeDotsFromTS($settings);
$htmlView = $objectManager->get(StandaloneView::class);
$htmlView->getTemplatePaths()->fillDefaultsByPackageName(
'templates_aide'
);
$htmlView->setTemplateRootPaths($templateRootPaths); $htmlView->setTemplateRootPaths($templateRootPaths);
$htmlView->setTemplate($templateNameHtml); $htmlView->setTemplate($templateNameHtml);
$textView = GeneralUtility::makeInstance(StandaloneView::class); $textView = $objectManager->get(StandaloneView::class);
$textView->getTemplatePaths()->fillDefaultsByPackageName(
'templates_aide'
);
$textView->setTemplateRootPaths($templateRootPaths); $textView->setTemplateRootPaths($templateRootPaths);
$textView->setTemplate($templateNameText); $textView->setTemplate($templateNameText);
$mail = GeneralUtility::makeInstance(MailMessage::class); $mail = GeneralUtility::makeInstance(MailMessage::class);
@ -172,7 +189,7 @@ class MailUtility
} }
$textView->assign('content', $bodydataText); $textView->assign('content', $bodydataText);
$htmlView->assign('content', $bodydataHtml); $htmlView->assign('content', $bodydataHtml);
$domain = GeneralUtility::locationHeaderUrl('/'); $domain = $settings['mailDomain'];
$htmlView->assign('domain', $domain); $htmlView->assign('domain', $domain);
$textBody = $textView->render(); $textBody = $textView->render();
$htmlBody = $htmlView->render(); $htmlBody = $htmlView->render();

View File

@ -0,0 +1 @@
<p>included content<p>