From ea43502633573370254c4d227d571488ce449734 Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Fri, 28 Jul 2017 09:47:02 +0200
Subject: [PATCH] [TASK] Refactoring category getter

---
 Classes/Service/Backend/Utility.php | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Classes/Service/Backend/Utility.php b/Classes/Service/Backend/Utility.php
index 7f4dbb9..132818b 100644
--- a/Classes/Service/Backend/Utility.php
+++ b/Classes/Service/Backend/Utility.php
@@ -42,6 +42,7 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
  */
 class Utility {
 	const CATEGORY_DOKTYPE = 117;
+	const NEWS_DOKTYPE = 117;
 
 	/**
 	 * create buttons for the backend module header
@@ -101,7 +102,7 @@ class Utility {
 	}
 
 	/**
-	 * Get an array of all category titles below the given site root id
+	 * Get an array of all category uids => >titles below the given site root id
 	 *
 	 * @param $siteRootPid
 	 * @throws \InvalidArgumentException
@@ -117,11 +118,13 @@ class Utility {
 		$databaseConnection = $GLOBALS['TYPO3_DB'];
 
 		$where = 'doktype = ' . self::CATEGORY_DOKTYPE . ' AND uid in (' . $childPids . ')';
-		$result = $databaseConnection->exec_SELECTquery('title', 'pages', $where)->fetch_all();
+		$result = $databaseConnection->exec_SELECTquery('uid, title', 'pages', $where)->fetch_all();
 		$categories = [];
-		foreach($result as $item) {
-			$categories[] = $item[0];
+		/** @var array $result */
+		foreach ($result as $item) {
+			$categories[$item[0]] = $item[1];
 		}
+
 		return $categories;
 	}
 }
-- 
GitLab