[BUGFIX] Adapt TCA signature for customControls to the documentation 17/57817/2
authorXavier Perseguers <xavier@typo3.org>
Tue, 10 Jul 2018 09:41:10 +0000 (11:41 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 5 Aug 2018 11:50:04 +0000 (13:50 +0200)
According to the documentation since TYPO3 v4.7, the definition of
"customControls" for "inline" columns should be a numerical array
with at least a "userFunc" key, just as any user function.

Releases: master, 8.7
Resolves: #83750
Change-Id: I2617cc9af9d642715b908296a2d75a3945b86cbb
Reviewed-on: https://review.typo3.org/57817
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83750-AdaptTCASignatureForInlineCustomControl.rst [new file with mode: 0644]

index 5db03f6..105f982 100644 (file)
@@ -323,15 +323,22 @@ class InlineControlContainer extends AbstractContainer
         if (is_array($config['customControls'])) {
             $html .= '<div id="' . $nameObject . '_customControls">';
             foreach ($config['customControls'] as $customControlConfig) {
+                if (!isset($customControlConfig['userFunc'])) {
+                    trigger_error('Support for customControl without a userFunc key will be removed in TYPO3 v10.', E_USER_DEPRECATED);
+                    $customControlConfig = [
+                        'userFunc' => $customControlConfig
+                    ];
+                }
                 $parameters = [
                     'table' => $table,
                     'field' => $field,
                     'row' => $row,
                     'nameObject' => $nameObject,
                     'nameForm' => $nameForm,
-                    'config' => $config
+                    'config' => $config,
+                    'customControlConfig' => $customControlConfig,
                 ];
-                $html .= GeneralUtility::callUserFunction($customControlConfig, $parameters, $this);
+                $html .= GeneralUtility::callUserFunction($customControlConfig['userFunc'], $parameters, $this);
             }
             $html .= '</div>';
         }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83750-AdaptTCASignatureForInlineCustomControl.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83750-AdaptTCASignatureForInlineCustomControl.rst
new file mode 100644 (file)
index 0000000..5c8c83d
--- /dev/null
@@ -0,0 +1,64 @@
+.. include:: ../../Includes.txt
+
+============================================================
+Deprecation: #83750 - Adapt TCA signature for customControls
+============================================================
+
+See :issue:`83750`
+
+Description
+===========
+
+According to the TCA documentation since TYPO3 v4.7, the definition of "customControls" for "inline" columns
+is as follows:
+
+    Numerical array containing definitions of custom header controls for IRRE fields. This makes it possible to
+    create special controls by calling user-defined functions (userFuncs). Each item in the array item must be
+    an array itself, with at least on key "userFunc" pointing to the user function to call.
+
+The implementation instead relied on the userFunc string being provided as the key of the array.
+
+
+Impact
+======
+
+TCA definition for "inline" fields using custom header controls for IIRE fields will trigger a deprecation:
+
+.. code-block:: php
+
+    'some-column' => [
+        'config' => [
+            'type' => 'inline',
+            // ...
+            'customControls' => [
+                \Vendor\MyExtension\Tca\MyFirstCustomControl::class . '->render',
+                \Vendor\MyExtension\Tca\MySecondCustomControl::class . '->render'
+            ]
+        ]
+    ]
+
+
+Migration
+=========
+
+Update the TCA definition with a `userFunc` key for specifying the method to be called:
+
+.. code-block:: php
+
+    'some-column' => [
+        'config' => [
+            'type' => 'inline',
+            // ...
+            'customControls' => [
+                [
+                    'userFunc' => \Vendor\MyExtension\Tca\MyFirstCustomControl::class . '->render'
+                ],
+                [
+                    'userFunc' => \Vendor\MyExtension\Tca\MySecondCustomControl::class . '->render'
+                ]
+            ]
+        ]
+    ]
+
+
+.. index:: TCA, NotScanned, ext:core