Skip to content
Snippets Groups Projects
Commit ea435026 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] Refactoring category getter

parent 786bd36a
No related branches found
No related tags found
1 merge request!2Feature be module
...@@ -42,6 +42,7 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility; ...@@ -42,6 +42,7 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
*/ */
class Utility { class Utility {
const CATEGORY_DOKTYPE = 117; const CATEGORY_DOKTYPE = 117;
const NEWS_DOKTYPE = 117;
/** /**
* create buttons for the backend module header * create buttons for the backend module header
...@@ -101,7 +102,7 @@ class Utility { ...@@ -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 * @param $siteRootPid
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
...@@ -117,11 +118,13 @@ class Utility { ...@@ -117,11 +118,13 @@ class Utility {
$databaseConnection = $GLOBALS['TYPO3_DB']; $databaseConnection = $GLOBALS['TYPO3_DB'];
$where = 'doktype = ' . self::CATEGORY_DOKTYPE . ' AND uid in (' . $childPids . ')'; $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 = []; $categories = [];
foreach($result as $item) { /** @var array $result */
$categories[] = $item[0]; foreach ($result as $item) {
$categories[$item[0]] = $item[1];
} }
return $categories; return $categories;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment