This commit is contained in:
Daniel Huf 2021-02-05 00:03:58 +01:00
parent ec45d511c2
commit 2f68fd32da
2 changed files with 7 additions and 5 deletions

View file

@ -11,12 +11,12 @@ class MjmlEmailFinisher extends \TYPO3\CMS\Form\Domain\Finishers\EmailFinisher
{ {
/** /**
* @param FormRuntime $formRuntime * @param FormRuntime $formRuntime
* @param string $format
* @return StandaloneView * @return StandaloneView
* @throws FinisherException * @throws FinisherException
*/ */
protected function initializeStandaloneView(FormRuntime $formRuntime): StandaloneView protected function initializeStandaloneView(FormRuntime $formRuntime, string $format): StandaloneView
{ {
$format = ucfirst($this->parseOption('format'));
$standaloneView = $this->objectManager->get(MjmlBasedView::class); $standaloneView = $this->objectManager->get(MjmlBasedView::class);
if (isset($this->options['templatePathAndFilename'])) { if (isset($this->options['templatePathAndFilename'])) {
@ -28,10 +28,12 @@ class MjmlEmailFinisher extends \TYPO3\CMS\Form\Domain\Finishers\EmailFinisher
if (!isset($this->options['templateName'])) { if (!isset($this->options['templateName'])) {
throw new FinisherException('The option "templateName" must be set for the EmailFinisher.', 1327058829); throw new FinisherException('The option "templateName" must be set for the EmailFinisher.', 1327058829);
} }
$this->options['templateName'] = strtr($this->options['templateName'], [ // Use local variable instead of augmenting the options to
// keep the format intact when sending multi-format mails
$templateName = strtr($this->options['templateName'], [
'{@format}' => $format '{@format}' => $format
]); ]);
$standaloneView->setTemplate($this->options['templateName']); $standaloneView->setTemplate($templateName);
} }
$standaloneView->assign('finisherVariableProvider', $this->finisherContext->getFinisherVariableProvider()); $standaloneView->assign('finisherVariableProvider', $this->finisherContext->getFinisherVariableProvider());

View file

@ -7,7 +7,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class MjmlBasedView extends StandaloneView class MjmlBasedView extends StandaloneView
{ {
protected RendererInterface $renderer; protected ?RendererInterface $renderer = null;
public function __construct(ContentObjectRenderer $contentObject = null, RendererInterface $renderer = null) public function __construct(ContentObjectRenderer $contentObject = null, RendererInterface $renderer = null)
{ {