[TASK] Use PageRepository in indexed search menu generation 92/58492/2
authorBenni Mack <benni@typo3.org>
Sun, 30 Sep 2018 11:33:26 +0000 (13:33 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Sun, 30 Sep 2018 20:21:43 +0000 (22:21 +0200)
Use your own instance of PageRepository instead of depending
on TSFE, and use the menu by using the global context
and restrictions by using PageRepository instead of custom
DB queries.

Resolves: #86472
Releases: master
Change-Id: Ia480caace4d7415a8b43abc36b7dda5e314c0712
Reviewed-on: https://review.typo3.org/58492
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/indexed_search/Classes/Controller/SearchController.php

index 7664bd0..e31c1b2 100644 (file)
@@ -32,6 +32,7 @@ use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\CMS\Core\Utility\RootlineUtility;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
+use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
  * Index search frontend
@@ -1353,29 +1354,11 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
      */
     protected function getMenuOfPages($pageUid)
     {
+        $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
         if ($this->settings['displayLevelxAllTypes']) {
-            $menu = [];
-            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
-            $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
-            $result = $queryBuilder
-                ->select('uid', 'title')
-                ->from('pages')
-                ->where(
-                    $queryBuilder->expr()->eq(
-                        'pid',
-                        $queryBuilder->createNamedParameter($pageUid, \PDO::PARAM_INT)
-                    )
-                )
-                ->orderBy('sorting')
-                ->execute();
-
-            while ($row = $result->fetch()) {
-                $menu[$row['uid']] = $GLOBALS['TSFE']->sys_page->getPageOverlay($row);
-            }
-        } else {
-            $menu = $GLOBALS['TSFE']->sys_page->getMenu($pageUid);
+            return $pageRepository->getMenuForPages([$pageUid]);
         }
-        return $menu;
+        return $pageRepository->getMenu($pageUid);
     }
 
     /**