[FOLLOWUP][TASK] FormEngine: Move SelectTree processing into a data provider 52/44352/3
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Thu, 29 Oct 2015 12:37:43 +0000 (13:37 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 29 Oct 2015 12:51:41 +0000 (13:51 +0100)
Extracted the target check into a dedicated method

Resolves: #69728
Releases: master
Change-Id: I24826cd8896444406066b93ffae330c22f933645
Reviewed-on: https://review.typo3.org/44352
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaSelectItems.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaSelectTreeItems.php

index 1a29d46..70522a4 100644 (file)
@@ -38,7 +38,7 @@ class TcaSelectItems extends AbstractItemProvider implements FormDataProviderInt
             }
 
             // Make sure we are only processing supported renderTypes
-            if (!in_array($fieldConfig['config']['renderType'], ['selectSingle', 'selectSingleBox', 'selectCheckBox', 'selectMultipleSideBySide'])) {
+            if ($this->isTargetRenderType($fieldConfig)) {
                 continue;
             }
 
@@ -80,4 +80,22 @@ class TcaSelectItems extends AbstractItemProvider implements FormDataProviderInt
 
         return $result;
     }
+
+    /**
+     * Determines whether the current field is a valid target for this DataProvider
+     *
+     * @param array $fieldConfig
+     * @return bool
+     */
+    protected function isTargetRenderType(array $fieldConfig)
+    {
+        if (!in_array(
+            $fieldConfig['config']['renderType'],
+            ['selectSingle', 'selectSingleBox', 'selectCheckBox', 'selectMultipleSideBySide'],
+            true
+        )) {
+            return true;
+        }
+        return false;
+    }
 }
index ca1af2e..13c76af 100644 (file)
@@ -42,7 +42,7 @@ class TcaSelectTreeItems extends AbstractItemProvider implements FormDataProvide
             }
 
             // Make sure we are only processing supported renderTypes
-            if ($fieldConfig['config']['renderType'] !== 'selectTree') {
+            if ($this->isTargetRenderType($fieldConfig)) {
                 continue;
             }
 
@@ -186,4 +186,18 @@ class TcaSelectTreeItems extends AbstractItemProvider implements FormDataProvide
 
         return $selectedNodes;
     }
+
+    /**
+     * Determines whether the current field is a valid target for this DataProvider
+     *
+     * @param array $fieldConfig
+     * @return bool
+     */
+    protected function isTargetRenderType(array $fieldConfig)
+    {
+        if ($fieldConfig['config']['renderType'] !== 'selectTree') {
+            return true;
+        }
+        return false;
+    }
 }