[BUGFIX] Use real finisher identifier in form element variants 06/59606/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Fri, 1 Feb 2019 12:51:40 +0000 (13:51 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 15:53:48 +0000 (16:53 +0100)
Use the real finisher identifiers as they are configured in the
form definition instead the finisher implementation class name.
This requires a change of the public AbstractFinisher implementation
which implements the FinisherInterface. The interface is not changed,
as this would be a breaking change. Therefore, the existence of the
new method is checked. If it does not exist in a finisher
implementation, a fallback to the previous behavior happens.

Releases: master, 9.5
Resolves: #87615
Change-Id: I962502f0601845a5f9793751e87c97b3b902caa1
Reviewed-on: https://review.typo3.org/59606
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/form/Classes/Domain/Finishers/AbstractFinisher.php
typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php

index 337ddab..f7f50ae 100644 (file)
@@ -95,6 +95,14 @@ abstract class AbstractFinisher implements FinisherInterface
     }
 
     /**
+     * @return string
+     */
+    public function getFinisherIdentifier(): string
+    {
+        return $this->finisherIdentifier;
+    }
+
+    /**
      * @param array $options configuration options in the format ['option1' => 'value1', 'option2' => 'value2', ...]
      */
     public function setOptions(array $options)
index 927d173..92ff959 100644 (file)
@@ -1044,8 +1044,12 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
 
         $finisherIdentifier = '';
         if ($this->getCurrentFinisher() !== null) {
-            $finisherIdentifier = (new \ReflectionClass($this->getCurrentFinisher()))->getShortName();
-            $finisherIdentifier = preg_replace('/Finisher$/', '', $finisherIdentifier);
+            if (method_exists($this->getCurrentFinisher(), 'getFinisherIdentifier')) {
+                $finisherIdentifier = $this->getCurrentFinisher()->getFinisherIdentifier();
+            } else {
+                $finisherIdentifier = (new \ReflectionClass($this->getCurrentFinisher()))->getShortName();
+                $finisherIdentifier = preg_replace('/Finisher$/', '', $finisherIdentifier);
+            }
         }
 
         return GeneralUtility::makeInstance(