From b02df7069ce76c5eed45e78b76be98314741a375 Mon Sep 17 00:00:00 2001
From: Benjamin Mack <benni@typo3.org>
Date: Sun, 16 Nov 2014 12:55:51 +0100
Subject: [PATCH] [TASK] Migrate leftover userfunc for tt_content to hook class

One method still initialized on every uncached call
is user_sortPluginList() which is used in TCA tt_content
to sort all plugins by name (trivial, right?).

The patch moves the code in the right direction.

Releases: master
Resolves: #63006
Change-Id: I9be865ee3429e033a924b00d0e1b98ad4159c15e
Reviewed-on: http://review.typo3.org/34244
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
---
 typo3/sysext/cms/ext_tables.php               | 13 +------
 .../Classes/Hooks/TableColumnHooks.php        | 35 +++++++++++++++++++
 .../frontend/Configuration/TCA/tt_content.php |  2 +-
 3 files changed, 37 insertions(+), 13 deletions(-)
 create mode 100644 typo3/sysext/frontend/Classes/Hooks/TableColumnHooks.php

diff --git a/typo3/sysext/cms/ext_tables.php b/typo3/sysext/cms/ext_tables.php
index 1a126e33391a..18600576d3a3 100644
--- a/typo3/sysext/cms/ext_tables.php
+++ b/typo3/sysext/cms/ext_tables.php
@@ -19,15 +19,4 @@ if (TYPO3_MODE === 'BE') {
 	);
 }
 // Add allowed records to pages:
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('pages_language_overlay,tt_content,sys_template,sys_domain,backend_layout');
-
-if (!function_exists('user_sortPluginList')) {
-	function user_sortPluginList(array &$parameters) {
-		usort(
-			$parameters['items'],
-			function ($item1, $item2) {
-				return strcasecmp($GLOBALS['LANG']->sL($item1[0]), $GLOBALS['LANG']->sL($item2[0]));
-			}
-		);
-	}
-}
\ No newline at end of file
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('pages_language_overlay,tt_content,sys_template,sys_domain,backend_layout');
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Classes/Hooks/TableColumnHooks.php b/typo3/sysext/frontend/Classes/Hooks/TableColumnHooks.php
new file mode 100644
index 000000000000..2746b90ae09d
--- /dev/null
+++ b/typo3/sysext/frontend/Classes/Hooks/TableColumnHooks.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace TYPO3\CMS\Frontend\Hooks;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Hooks / manipulation data for TCA columns e.g. to sort items within itemsProcFunc
+ */
+class TableColumnHooks {
+
+	/**
+	 * sort list items (used for plugins, list_type) by name
+	 * @param array $parameters
+	 */
+	public function sortPluginList(array &$parameters) {
+		usort(
+			$parameters['items'],
+			function ($item1, $item2) {
+				return strcasecmp($GLOBALS['LANG']->sL($item1[0]), $GLOBALS['LANG']->sL($item2[0]));
+			}
+		);
+	}
+}
\ No newline at end of file
diff --git a/typo3/sysext/frontend/Configuration/TCA/tt_content.php b/typo3/sysext/frontend/Configuration/TCA/tt_content.php
index 0281b80b2715..da0af85197b6 100644
--- a/typo3/sysext/frontend/Configuration/TCA/tt_content.php
+++ b/typo3/sysext/frontend/Configuration/TCA/tt_content.php
@@ -1189,7 +1189,7 @@ return array(
 						''
 					)
 				),
-				'itemsProcFunc' => 'user_sortPluginList',
+				'itemsProcFunc' => 'TYPO3\\CMS\\Frontend\\Hooks\\TableColumnHooks->sortPluginList',
 				'default' => '',
 				'authMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'],
 				'iconsInOptionTags' => 1,
-- 
GitLab