[BUGFIX] EXT:form - fix templateRootPaths support for email finishers 92/53692/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Fri, 30 Jun 2017 09:17:05 +0000 (11:17 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Mon, 14 Aug 2017 13:32:39 +0000 (15:32 +0200)
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/53692
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php
typo3/sysext/form/Configuration/Yaml/BaseSetup.yaml

index cd6958e..4bc3be3 100644 (file)
@@ -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']);
         }
index 2d3b04c..12f2caf 100644 (file)
@@ -401,7 +401,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: {}