From 8ae6313cf4152422940124cfcadbafc3dd1354c5 Mon Sep 17 00:00:00 2001 From: Ralf Zimmermann <ralf.zimmermann@tritum.de> Date: Fri, 30 Jun 2017 11:17:05 +0200 Subject: [PATCH] [BUGFIX] EXT:form - fix templateRootPaths support for email finishers Fixes "templateRootPaths" support for email finishers. "templatePathAndFilename" is still functional to avoid breaking changes. Resolves: #80974 Releases: master, 8.7 Change-Id: Ic8055a925c0608a9166f98b52c34435ac2a56082 Reviewed-on: https://review.typo3.org/53365 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Frans Saris <franssaris@gmail.com> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Frans Saris <franssaris@gmail.com> Reviewed-by: Joerg Boesche <typo3@joergboesche.de> Reviewed-by: Tobi Kretschmann <tobi@tobishome.de> Reviewed-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com> Reviewed-by: Susanne Moog <susanne.moog@typo3.org> Tested-by: Susanne Moog <susanne.moog@typo3.org> --- .../Domain/Finishers/EmailFinisher.php | 28 +++++++++++++------ .../form/Configuration/Yaml/BaseSetup.yaml | 4 ++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php b/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php index cd6958eb21d9..4bc3be30d9e4 100644 --- a/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php +++ b/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php @@ -159,20 +159,30 @@ class EmailFinisher extends AbstractFinisher */ protected function initializeStandaloneView(FormRuntime $formRuntime): StandaloneView { - if (!isset($this->options['templatePathAndFilename'])) { - throw new FinisherException('The option "templatePathAndFilename" must be set for the EmailFinisher.', 1327058829); - } - $format = ucfirst($this->parseOption('format')); + $standaloneView = $this->objectManager->get(StandaloneView::class); - $this->options['templatePathAndFilename'] = strtr($this->options['templatePathAndFilename'], [ - '{@format}' => $format - ]); + if (isset($this->options['templatePathAndFilename'])) { + $this->options['templatePathAndFilename'] = strtr($this->options['templatePathAndFilename'], [ + '{@format}' => $format + ]); + $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']); + } else { + if (!isset($this->options['templateName'])) { + throw new FinisherException('The option "templateName" must be set for the EmailFinisher.', 1327058829); + } + $this->options['templateName'] = strtr($this->options['templateName'], [ + '{@format}' => $format + ]); + $standaloneView->setTemplate($this->options['templateName']); + } - $standaloneView = $this->objectManager->get(StandaloneView::class); - $standaloneView->setTemplatePathAndFilename($this->options['templatePathAndFilename']); $standaloneView->assign('finisherVariableProvider', $this->finisherContext->getFinisherVariableProvider()); + if (isset($this->options['templateRootPaths']) && is_array($this->options['templateRootPaths'])) { + $standaloneView->setTemplateRootPaths($this->options['templateRootPaths']); + } + if (isset($this->options['partialRootPaths']) && is_array($this->options['partialRootPaths'])) { $standaloneView->setPartialRootPaths($this->options['partialRootPaths']); } diff --git a/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml b/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml index f0deb59eaa8f..821125314f37 100644 --- a/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml +++ b/typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml @@ -398,7 +398,9 @@ TYPO3: #translation: # language: 'default' # {@format} depends the 'format' value - templatePathAndFilename: 'EXT:form/Resources/Private/Frontend/Templates/Finishers/Email/{@format}.html' + templateName: '{@format}.html' + templateRootPaths: + 10: 'EXT:form/Resources/Private/Frontend/Templates/Finishers/Email/' #partialRootPaths: [] #layoutRootPaths: [] #variables: {} -- GitLab