From e2b465b304de388028bd8f810f2a0af03d7ad9fd Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Mon, 28 Sep 2020 12:04:14 +0200
Subject: [PATCH] [TASK] Deprecate StandaloneView for EXT:form EmailFinisher

With #90728 FluidEmail was added to the EXT:form EmailFinisher.
Therefore the StandaloneView has now been deprecated along with
the corresponding configuration option `templatePathAndFilename`,
which can't be used for FluidEmail.

Resolves: #92435
Releases: master
Change-Id: Iabda1d36b03f347d752f19452c2e3392990d303d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65921
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Marcus Schwemer <ms@schwemer.de>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 ...precatedStandaloneViewForEmailFinisher.rst | 80 +++++++++++++++++++
 .../Domain/Finishers/EmailFinisher.php        | 11 +++
 2 files changed, 91 insertions(+)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-92435-DeprecatedStandaloneViewForEmailFinisher.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-92435-DeprecatedStandaloneViewForEmailFinisher.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-92435-DeprecatedStandaloneViewForEmailFinisher.rst
new file mode 100644
index 000000000000..8f71916ed350
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-92435-DeprecatedStandaloneViewForEmailFinisher.rst
@@ -0,0 +1,80 @@
+.. include:: ../../Includes.txt
+
+=================================================================
+Deprecation: #92435 - Deprecated StandaloneView for EmailFinisher
+=================================================================
+
+See :issue:`92435`
+
+Description
+===========
+
+The :php:`EmailFinisher` of EXT:form was extended for the possibility to use
+FluidEmail in TYPO3 10. Therefore the previously used StandaloneView has now been
+deprecated along with the configuration option :yaml:`templatePathAndFilename`.
+
+
+Impact
+======
+
+Using the StandaloneView will trigger a deprecation log warning. Using
+:yaml:`templatePathAndFilename` for custom templates will also trigger a
+deprecation log warning.
+
+
+Affected Installations
+======================
+
+All installations not already using FluidEmail for the EXT:form EmailFinisher.
+
+
+Migration
+=========
+
+Adjust your finisher configuration to use FluidEmail by setting :yaml:`useFluidEmail: true`.
+
+Before:
+
+.. code-block:: yaml
+
+    finishers:
+       -
+         identifier: EmailToReceiver
+         options:
+           useFluidEmail: false
+
+After:
+
+.. code-block:: yaml
+
+   finishers:
+     -
+       identifier: EmailToReceiver
+       options:
+         useFluidEmail: true
+
+For custom templates, replace :yaml:`templatePathAndFilename` with :yaml:`templateName`
+and :yaml:`templateRootPaths`.
+
+Before:
+
+.. code-block:: yaml
+
+    finishersDefinition:
+      EmailToReceiver:
+        options:
+          templatePathAndFilename: EXT:sitepackage/Resources/Private/Templates/Email/ContactForm.html
+
+After:
+
+.. code-block:: yaml
+
+   finishersDefinition:
+     EmailToReceiver:
+       options:
+         templateName: ContactForm
+         templateRootPaths:
+           100: 'EXT:sitepackage/Resources/Private/Templates/Email/'
+
+
+.. index:: YAML, NotScanned, ext:form
diff --git a/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php b/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php
index 1e0d81683605..3032283f671b 100644
--- a/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php
+++ b/typo3/sysext/form/Classes/Domain/Finishers/EmailFinisher.php
@@ -198,12 +198,23 @@ class EmailFinisher extends AbstractFinisher
      * @param string $format
      * @return StandaloneView
      * @throws FinisherException
+     * @deprecated since v11, will be removed in v12
      */
     protected function initializeStandaloneView(FormRuntime $formRuntime, string $format): StandaloneView
     {
+        trigger_error(
+            'Using StandaloneView for EmailFinisher \'' . $this->finisherIdentifier . '\' is deprecated and will be removed in v12. Please use FluidEmail in the finishers configuration instead.',
+            E_USER_DEPRECATED
+        );
+
         $standaloneView = GeneralUtility::makeInstance(StandaloneView::class);
 
         if (isset($this->options['templatePathAndFilename'])) {
+            trigger_error(
+                'The option \'templatePathAndFilename\' for EmailFinisher \'' . $this->finisherIdentifier . '\' is deprecated and will be removed in v12. Please use \'templateName\' and \'templateRootPaths\' in the finishers definition instead.',
+                E_USER_DEPRECATED
+            );
+
             $this->options['templatePathAndFilename'] = strtr($this->options['templatePathAndFilename'], [
                 '{@format}' => $format
             ]);
-- 
GitLab