[BUGFIX] Finishers with output must return the output 65/56665/3
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Sun, 15 Apr 2018 08:32:33 +0000 (10:32 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 15 Apr 2018 08:47:06 +0000 (10:47 +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/56665
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 b5a2cc9..7dbc38f 100644 (file)
@@ -116,12 +116,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();
     }
 
     /**
@@ -129,6 +130,7 @@ abstract class AbstractFinisher implements FinisherInterface
      *
      * Override and fill with your own implementation!
      *
+     * @return string|null
      * @api
      */
     abstract protected function executeInternal();
index 07188b0..610d3bb 100644 (file)
@@ -51,14 +51,15 @@ class ConfirmationFinisher extends AbstractFinisher
 
     /**
      * Executes this finisher
+     *
      * @see AbstractFinisher::execute()
+     * @return string
      *
      * @throws FinisherException
      */
     protected function executeInternal()
     {
-        $formRuntime = $this->finisherContext->getFormRuntime();
         $message = $this->parseOption('message');
-        $formRuntime->getResponse()->setContent($message);
+        return $message;
     }
 }
index b6330a2..54b1fdf 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 fd52bbc..0e0a781 100644 (file)
@@ -540,8 +540,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());
@@ -564,20 +563,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;
     }
 
     /**