[TASK] Deprecate BackendUtility::getTCAtypes 87/57887/3
authorWouter Wolters <typo3@wouterwolters.nl>
Mon, 13 Aug 2018 18:33:21 +0000 (20:33 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Tue, 14 Aug 2018 11:27:36 +0000 (13:27 +0200)
Resolves: #85836
Releases: master
Change-Id: I7480cc7ddd6a661a6b13e43ed7dfbc5d0783763f
Reviewed-on: https://review.typo3.org/57887
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php
typo3/sysext/backend/Tests/UnitDeprecated/Utility/BackendUtilityTest.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85836-DeprecateBackendUtilitygetTCAtypes.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php

index f71e375..37fe2ef 100644 (file)
@@ -67,6 +67,7 @@ class BackendUtility
      *
      * @var array
      * @see self::getTCAtypes()
+     * @deprecated since TYPO3 v9.4 will be removed in TYPO3 v10.0.
      */
     protected static $tcaTableTypeConfigurationCache = [];
 
@@ -636,9 +637,11 @@ class BackendUtility
      * @param array $rec Record from $table
      * @param bool $useFieldNameAsKey If $useFieldNameAsKey is set, then the fieldname is associative keys in the return array, otherwise just numeric keys.
      * @return array|null
+     * @deprecated since TYPO3 v9.4 will be removed in TYPO3 v10.0.
      */
     public static function getTCAtypes($table, $rec, $useFieldNameAsKey = false)
     {
+        trigger_error('BackendUtility::getTCAtypes will be removed in TYPO3 v10. The method is not in use anymore.', E_USER_DEPRECATED);
         if (isset($GLOBALS['TCA'][$table])) {
             // Get type value:
             $fieldValue = self::getTCAtypeValue($table, $rec);
@@ -727,7 +730,6 @@ class BackendUtility
      * @param array $row Record from $table
      * @throws \RuntimeException
      * @return string Field value
-     * @see getTCAtypes()
      */
     public static function getTCAtypeValue($table, $row)
     {
index 1f9fbf4..1d9ff58 100644 (file)
@@ -896,264 +896,6 @@ class BackendUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->assertSame('24-03-16 (-1 day)', BackendUtility::dateTimeAge($GLOBALS['EXEC_TIME'] + 86400, 1, 'date'));
     }
 
-    ///////////////////////////////////////
-    // Tests concerning getTCAtypes
-    ///////////////////////////////////////
-
-    /**
-     * @test
-     */
-    public function getTCAtypesReturnsCorrectValuesDataProvider()
-    {
-        return [
-            'no input' => [
-                '', // table
-                [], // rec
-                '', // useFieldNameAsKey
-                null // expected
-            ],
-            'non-existant table' => [
-                'fooBar', // table
-                [], // rec
-                '', // useFieldNameAsKey
-                null // expected
-            ],
-            'Doktype=1: one simple field' => [
-                'pages',
-                [
-                    'uid' => '1',
-                    'doktype' => '1'
-                ],
-                false,
-                [
-                    0 => [
-                        'field' => 'title',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'title'
-                    ]
-                ]
-            ],
-            'non-existant type given: Return for type 1' => [
-                'pages', // table
-                [
-                    'uid' => '1',
-                    'doktype' => '999'
-                ], // rec
-                '', // useFieldNameAsKey
-                [
-                    0 => [
-                        'field' => 'title',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'title'
-                    ]
-                ] // expected
-            ],
-            'Doktype=1: one simple field, useFieldNameAsKey=true' => [
-                'pages',
-                [
-                    'uid' => '1',
-                    'doktype' => '1'
-                ],
-                true,
-                [
-                    'title' => [
-                        'field' => 'title',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'title'
-                    ]
-                ]
-            ],
-            'Empty showitem Field' => [
-                'test',
-                [
-                    'uid' => '1',
-                    'fooBar' => '99'
-                ],
-                true,
-                [
-                    '' => [
-                        'field' => '',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => ''
-                    ]
-                ]
-            ],
-            'RTE field within a palette' => [
-                'pages',
-                [
-                    'uid' => '1',
-                    'doktype' => '10',
-                ],
-                false,
-                [
-                    0 => [
-                        'field' => '--div--',
-                        'title' => 'General',
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => '--div--;General'
-                    ],
-                    1 => [
-                        'field' => '--palette--',
-                        'title' => 'Palette',
-                        'palette' => '123',
-                        'spec' => [],
-                        'origString' => '--palette--;Palette;123'
-                    ],
-                    2 => [
-                        'field' => 'title',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'title'
-                    ],
-                    3 => [
-                        'field' => 'text',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'text'
-                    ],
-                    4 => [
-                        'field' => 'select',
-                        'title' => 'Select field',
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'select;Select field'
-                    ]
-                ]
-            ],
-            'RTE field with more settings within a palette' => [
-                'pages',
-                [
-                    'uid' => 1,
-                    'doktype' => 2
-                ],
-                false,
-                [
-                    0 => [
-                        'field' => '--div--',
-                        'title' => 'General',
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => '--div--;General'
-                    ],
-                    1 => [
-                        'field' => '--palette--',
-                        'title' => 'RTE palette',
-                        'palette' => '456',
-                        'spec' => [],
-                        'origString' => '--palette--;RTE palette;456'
-                    ],
-                    2 => [
-                        'field' => 'text2',
-                        'title' => null,
-                        'palette' => null,
-                        'spec' => [],
-                        'origString' => 'text2'
-                    ]
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @test
-     * @dataProvider getTCAtypesReturnsCorrectValuesDataProvider
-     *
-     * @param string $table
-     * @param array $rec
-     * @param bool $useFieldNameAsKey
-     * @param array $expected
-     */
-    public function getTCAtypesReturnsCorrectValues($table, $rec, $useFieldNameAsKey, $expected)
-    {
-        $GLOBALS['TCA'] = [
-            'pages' => [
-                'ctrl' => [
-                    'type' => 'doktype'
-                ],
-                'columns' => [
-                    'title' => [
-                        'label' => 'Title test',
-                        'config' => [
-                            'type' => 'input'
-                        ]
-                    ],
-                    'text' => [
-                        'label' => 'RTE Text',
-                        'config' => [
-                            'type' => 'text',
-                            'cols' => 40,
-                            'rows' => 5
-                        ],
-                    ],
-                    'text2' => [
-                        'label' => 'RTE Text 2',
-                        'config' => [
-                            'type' => 'text',
-                            'cols' => 40,
-                            'rows' => 5
-                        ],
-                    ],
-                    'select' => [
-                        'label' => 'Select test',
-                        'config' => [
-                            'items' => [
-                                ['Please select', 0],
-                                ['Option 1', 1],
-                                ['Option 2', 2]
-                            ]
-                        ],
-                        'maxitems' => 1,
-                        'renderType' => 'selectSingle'
-                    ]
-                ],
-                'types' => [
-                    '1' => [
-                        'showitem' => 'title'
-                    ],
-                    '2' => [
-                        'showitem' => '--div--;General,--palette--;RTE palette;456'
-                    ],
-                    '10' => [
-                        'showitem' => '--div--;General,--palette--;Palette;123,title'
-                    ],
-                    '14' => [
-                        'showitem' => '--div--;General,title'
-                    ]
-                ],
-                'palettes' => [
-                    '123' => [
-                        'showitem' => 'text,select;Select field'
-                    ],
-                    '456' => [
-                        'showitem' => 'text2'
-                    ]
-                ]
-            ],
-            'test' => [
-                'ctrl' => [
-                    'type' => 'fooBar'
-                ],
-                'types' => [
-                    '99' => [ 'showitem' => '']
-                ]
-            ]
-        ];
-
-        $return = BackendUtility::getTCAtypes($table, $rec, $useFieldNameAsKey);
-        $this->assertSame($expected, $return);
-    }
-
     /**
      * @test
      */
index db88adf..3f9c725 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Utility;
  */
 
 use TYPO3\CMS\Backend\Tests\UnitDeprecated\Utility\Fixtures\BackendUtilityFixture;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -47,4 +48,262 @@ class BackendUtilityTest extends UnitTestCase
 
         $this->assertSame($completeConfiguration, BackendUtilityFixture::getModTSconfig(42, 'notrelevant'));
     }
+
+    ///////////////////////////////////////
+    // Tests concerning getTCAtypes
+    ///////////////////////////////////////
+
+    /**
+     * @test
+     */
+    public function getTCAtypesReturnsCorrectValuesDataProvider()
+    {
+        return [
+            'no input' => [
+                '', // table
+                [], // rec
+                '', // useFieldNameAsKey
+                null // expected
+            ],
+            'non-existant table' => [
+                'fooBar', // table
+                [], // rec
+                '', // useFieldNameAsKey
+                null // expected
+            ],
+            'Doktype=1: one simple field' => [
+                'pages',
+                [
+                    'uid' => '1',
+                    'doktype' => '1'
+                ],
+                false,
+                [
+                    0 => [
+                        'field' => 'title',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'title'
+                    ]
+                ]
+            ],
+            'non-existant type given: Return for type 1' => [
+                'pages', // table
+                [
+                    'uid' => '1',
+                    'doktype' => '999'
+                ], // rec
+                '', // useFieldNameAsKey
+                [
+                    0 => [
+                        'field' => 'title',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'title'
+                    ]
+                ] // expected
+            ],
+            'Doktype=1: one simple field, useFieldNameAsKey=true' => [
+                'pages',
+                [
+                    'uid' => '1',
+                    'doktype' => '1'
+                ],
+                true,
+                [
+                    'title' => [
+                        'field' => 'title',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'title'
+                    ]
+                ]
+            ],
+            'Empty showitem Field' => [
+                'test',
+                [
+                    'uid' => '1',
+                    'fooBar' => '99'
+                ],
+                true,
+                [
+                    '' => [
+                        'field' => '',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => ''
+                    ]
+                ]
+            ],
+            'RTE field within a palette' => [
+                'pages',
+                [
+                    'uid' => '1',
+                    'doktype' => '10',
+                ],
+                false,
+                [
+                    0 => [
+                        'field' => '--div--',
+                        'title' => 'General',
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => '--div--;General'
+                    ],
+                    1 => [
+                        'field' => '--palette--',
+                        'title' => 'Palette',
+                        'palette' => '123',
+                        'spec' => [],
+                        'origString' => '--palette--;Palette;123'
+                    ],
+                    2 => [
+                        'field' => 'title',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'title'
+                    ],
+                    3 => [
+                        'field' => 'text',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'text'
+                    ],
+                    4 => [
+                        'field' => 'select',
+                        'title' => 'Select field',
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'select;Select field'
+                    ]
+                ]
+            ],
+            'RTE field with more settings within a palette' => [
+                'pages',
+                [
+                    'uid' => 1,
+                    'doktype' => 2
+                ],
+                false,
+                [
+                    0 => [
+                        'field' => '--div--',
+                        'title' => 'General',
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => '--div--;General'
+                    ],
+                    1 => [
+                        'field' => '--palette--',
+                        'title' => 'RTE palette',
+                        'palette' => '456',
+                        'spec' => [],
+                        'origString' => '--palette--;RTE palette;456'
+                    ],
+                    2 => [
+                        'field' => 'text2',
+                        'title' => null,
+                        'palette' => null,
+                        'spec' => [],
+                        'origString' => 'text2'
+                    ]
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @test
+     * @dataProvider getTCAtypesReturnsCorrectValuesDataProvider
+     *
+     * @param string $table
+     * @param array $rec
+     * @param bool $useFieldNameAsKey
+     * @param array $expected
+     */
+    public function getTCAtypesReturnsCorrectValues($table, $rec, $useFieldNameAsKey, $expected)
+    {
+        $GLOBALS['TCA'] = [
+            'pages' => [
+                'ctrl' => [
+                    'type' => 'doktype'
+                ],
+                'columns' => [
+                    'title' => [
+                        'label' => 'Title test',
+                        'config' => [
+                            'type' => 'input'
+                        ]
+                    ],
+                    'text' => [
+                        'label' => 'RTE Text',
+                        'config' => [
+                            'type' => 'text',
+                            'cols' => 40,
+                            'rows' => 5
+                        ],
+                    ],
+                    'text2' => [
+                        'label' => 'RTE Text 2',
+                        'config' => [
+                            'type' => 'text',
+                            'cols' => 40,
+                            'rows' => 5
+                        ],
+                    ],
+                    'select' => [
+                        'label' => 'Select test',
+                        'config' => [
+                            'items' => [
+                                ['Please select', 0],
+                                ['Option 1', 1],
+                                ['Option 2', 2]
+                            ]
+                        ],
+                        'maxitems' => 1,
+                        'renderType' => 'selectSingle'
+                    ]
+                ],
+                'types' => [
+                    '1' => [
+                        'showitem' => 'title'
+                    ],
+                    '2' => [
+                        'showitem' => '--div--;General,--palette--;RTE palette;456'
+                    ],
+                    '10' => [
+                        'showitem' => '--div--;General,--palette--;Palette;123,title'
+                    ],
+                    '14' => [
+                        'showitem' => '--div--;General,title'
+                    ]
+                ],
+                'palettes' => [
+                    '123' => [
+                        'showitem' => 'text,select;Select field'
+                    ],
+                    '456' => [
+                        'showitem' => 'text2'
+                    ]
+                ]
+            ],
+            'test' => [
+                'ctrl' => [
+                    'type' => 'fooBar'
+                ],
+                'types' => [
+                    '99' => [ 'showitem' => '']
+                ]
+            ]
+        ];
+
+        $return = BackendUtility::getTCAtypes($table, $rec, $useFieldNameAsKey);
+        $this->assertSame($expected, $return);
+    }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85836-DeprecateBackendUtilitygetTCAtypes.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85836-DeprecateBackendUtilitygetTCAtypes.rst
new file mode 100644 (file)
index 0000000..ec7bcd3
--- /dev/null
@@ -0,0 +1,32 @@
+.. include:: ../../Includes.txt
+
+===========================================================
+Deprecation: #85836 - Deprecate BackendUtility::getTCAtypes
+===========================================================
+
+See :issue:`85836`
+
+Description
+===========
+
+The method :php:`BackendUtility::getTCAtypes` has been marked as deprecated and will be removed in TYPO3 v10.
+
+
+Impact
+======
+
+Calling the mentioned method will trigger a deprecation warning.
+
+
+Affected Installations
+======================
+
+Third party code which accesses the method.
+
+
+Migration
+=========
+
+No migration available.
+
+.. index:: Backend, FullyScanned, ext:backend
\ No newline at end of file
index e3336c2..4ec3be3 100644 (file)
@@ -722,4 +722,11 @@ return [
             'Deprecation-85822-DeprecatePageGeneratorrenderContent.rst',
         ],
     ],
+    'TYPO3\CMS\Backend\Utility\BackendUtility::getTCAtypes' => [
+        'numberOfMandatoryArguments' => 2,
+        'maximumNumberOfArguments' => 3,
+        'restFiles' => [
+            'Deprecation-85836-DeprecateBackendUtilitygetTCAtypes.rst',
+        ],
+    ],
 ];