[BUGFIX] Finishers with output must return the output 77/56377/7
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Tue, 20 Mar 2018 11:28:38 +0000 (12:28 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 15 Apr 2018 08:29:34 +0000 (10:29 +0200)
Since #83822 EXT:form makes usage of the controller context
response object which has impacts to the finisher logic which was not
treated by #83822.
Now, finishers with output can return this as string instead of setting
this directly into the response (which results in a double output).

Resolves: #84495
Releases: master, 8.7
Change-Id: Ib5accba1004b857b5447ae26dff8a689acfa6579
Reviewed-on: https://review.typo3.org/56377
Reviewed-by: Richard Haeser <richard@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Manuel Selbach <manuel_selbach@yahoo.de>
Tested-by: Manuel Selbach <manuel_selbach@yahoo.de>
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Tested-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/form/Classes/Domain/Finishers/AbstractFinisher.php
typo3/sysext/form/Classes/Domain/Finishers/ConfirmationFinisher.php
typo3/sysext/form/Classes/Domain/Finishers/FinisherInterface.php
typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php

index 5722b62..3164068 100644 (file)
@@ -117,12 +117,13 @@ abstract class AbstractFinisher implements FinisherInterface
      * Executes the finisher
      *
      * @param FinisherContext $finisherContext The Finisher context that contains the current Form Runtime and Response
+     * @return string|null
      * @api
      */
     final public function execute(FinisherContext $finisherContext)
     {
         $this->finisherContext = $finisherContext;
-        $this->executeInternal();
+        return $this->executeInternal();
     }
 
     /**
@@ -130,6 +131,7 @@ abstract class AbstractFinisher implements FinisherInterface
      *
      * Override and fill with your own implementation!
      *
+     * @return string|null
      * @api
      */
     abstract protected function executeInternal();
index dec2fae..c4dbeb9 100644 (file)
@@ -83,14 +83,14 @@ class ConfirmationFinisher extends AbstractFinisher
 
     /**
      * Executes this finisher
+     *
      * @see AbstractFinisher::execute()
+     * @return string
      *
      * @throws FinisherException
      */
     protected function executeInternal()
     {
-        $formRuntime = $this->finisherContext->getFormRuntime();
-
         $contentElementUid = (int)$this->parseOption('contentElementUid');
         $typoscriptObjectPath = $this->parseOption('typoscriptObjectPath');
         if ($contentElementUid > 0) {
@@ -113,6 +113,6 @@ class ConfirmationFinisher extends AbstractFinisher
             $message = $this->parseOption('message');
         }
 
-        $formRuntime->getResponse()->setContent($message);
+        return $message;
     }
 }
index e9a1ea2..ba0bfcd 100644 (file)
@@ -30,6 +30,7 @@ interface FinisherInterface
      * Executes the finisher
      *
      * @param FinisherContext $finisherContext The Finisher context that contains the current Form Runtime and Response
+     * @return string|null
      * @api
      */
     public function execute(FinisherContext $finisherContext);
index 8433518..32cad29 100644 (file)
@@ -514,8 +514,7 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
     public function render()
     {
         if ($this->isAfterLastPage()) {
-            $this->invokeFinishers();
-            return $this->response->getContent();
+            return $this->invokeFinishers();
         }
 
         $this->formState->setLastDisplayedPageIndex($this->currentPage->getIndex());
@@ -538,20 +537,29 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
 
     /**
      * Executes all finishers of this form
+     *
+     * @return string
      */
-    protected function invokeFinishers()
+    protected function invokeFinishers(): string
     {
         $finisherContext = $this->objectManager->get(
             FinisherContext::class,
             $this,
             $this->getControllerContext()
         );
+
+        $output = '';
         foreach ($this->formDefinition->getFinishers() as $finisher) {
-            $finisher->execute($finisherContext);
+            $finisherOutput = $finisher->execute($finisherContext);
+            if (is_string($finisherOutput) && !empty($finisherOutput)) {
+                $output .= $finisherOutput;
+            }
             if ($finisherContext->isCancelled()) {
                 break;
             }
         }
+
+        return $output;
     }
 
     /**