Skip to content

Commit

Permalink
[TASK] Replace setContent with new moduleTemplate API (#4054)
Browse files Browse the repository at this point in the history
Fixes: #4058
Relates: #4043
  • Loading branch information
sfroemkenjw committed May 16, 2024
1 parent c041364 commit 0de5a2a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 42 deletions.
13 changes: 2 additions & 11 deletions Classes/Controller/Backend/Search/AbstractModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ protected function initializeView($view): void
$sites = $this->siteRepository->getAvailableSites();

$selectOtherPage = count($sites) > 0 || $this->selectedPageUID < 1;
$this->view->assign('showSelectOtherPage', $selectOtherPage);
$this->view->assign('pageUID', $this->selectedPageUID);
$this->moduleTemplate->assign('showSelectOtherPage', $selectOtherPage);
$this->moduleTemplate->assign('pageUID', $this->selectedPageUID);
if ($this->selectedPageUID < 1) {
return;
}
Expand Down Expand Up @@ -257,15 +257,6 @@ public function switchCoreAction(string $corePath, string $uriToRedirectTo): Res
return new RedirectResponse($uriToRedirectTo, 303);
}

/**
* Returns the Response for be module action.
*/
protected function getModuleTemplateResponse(): ResponseInterface
{
$this->moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($this->moduleTemplate->renderContent());
}

/**
* Initializes the solr core connection considerately to the components state.
* Uses and persists default core connection if persisted core in Site does not exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function initializeView($view): void

$this->generateCoreSelectorMenuUsingPageTree();
$coreOptimizationTabs = $this->moduleTemplate->getDynamicTabMenu([], 'coreOptimization');
$this->view->assign('tabs', $coreOptimizationTabs);
$this->moduleTemplate->assign('tabs', $coreOptimizationTabs);
}

/**
Expand All @@ -54,8 +54,8 @@ protected function initializeView($view): void
public function indexAction(): ResponseInterface
{
if ($this->selectedSolrCoreConnection === null) {
$this->view->assign('can_not_proceed', true);
return $this->getModuleTemplateResponse();
$this->moduleTemplate->assign('can_not_proceed', true);
return $this->moduleTemplate->renderResponse('Index');
}

$synonyms = [];
Expand All @@ -66,13 +66,13 @@ public function indexAction(): ResponseInterface
}

$stopWords = $coreAdmin->getStopWords();
$this->view->assignMultiple([
$this->moduleTemplate->assignMultiple([
'synonyms' => $synonyms,
'stopWords' => implode(PHP_EOL, $stopWords),
'stopWordsCount' => count($stopWords),
]);

return $this->getModuleTemplateResponse();
return $this->moduleTemplate->renderResponse('Index');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class IndexAdministrationModuleController extends AbstractModuleController
public function indexAction(): ResponseInterface
{
if ($this->selectedSite === null || empty($this->solrConnectionManager->getConnectionsBySite($this->selectedSite))) {
$this->view->assign('can_not_proceed', true);
$this->moduleTemplate->assign('can_not_proceed', true);
}
return $this->getModuleTemplateResponse();
return $this->moduleTemplate->renderResponse('Index');
}

/**
Expand Down
16 changes: 8 additions & 8 deletions Classes/Controller/Backend/Search/IndexQueueModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public function indexAction(): ResponseInterface
{
$this->initializeAction();
if (!$this->canQueueSelectedSite()) {
$this->view->assign('can_not_proceed', true);
return $this->getModuleTemplateResponse();
$this->moduleTemplate->assign('can_not_proceed', true);
return $this->moduleTemplate->renderResponse('Index');
}

$statistics = $this->indexQueue->getStatisticsBySite($this->selectedSite);
$this->view->assign('indexQueueInitializationSelector', $this->getIndexQueueInitializationSelector());
$this->view->assign('indexqueue_statistics', $statistics);
$this->view->assign('indexqueue_errors', $this->indexQueue->getErrorsBySite($this->selectedSite));
return $this->getModuleTemplateResponse();
$this->moduleTemplate->assign('indexQueueInitializationSelector', $this->getIndexQueueInitializationSelector());
$this->moduleTemplate->assign('indexqueue_statistics', $statistics);
$this->moduleTemplate->assign('indexqueue_errors', $this->indexQueue->getErrorsBySite($this->selectedSite));
return $this->moduleTemplate->renderResponse('Index');
}

/**
Expand Down Expand Up @@ -270,8 +270,8 @@ public function showErrorAction(int $indexQueueItemId): ResponseInterface
return new RedirectResponse($this->uriBuilder->uriFor('index'), 303);
}

$this->view->assign('indexQueueItem', $item);
return $this->getModuleTemplateResponse();
$this->moduleTemplate->assign('indexQueueItem', $item);
return $this->moduleTemplate->renderResponse('ShowError');
}

/**
Expand Down
32 changes: 16 additions & 16 deletions Classes/Controller/Backend/Search/InfoModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ public function indexAction(): ResponseInterface
{
$this->initializeAction();
if ($this->selectedSite === null) {
$this->view->assign('can_not_proceed', true);
return $this->getModuleTemplateResponse();
$this->moduleTemplate->assign('can_not_proceed', true);
return $this->moduleTemplate->renderResponse('Index');
}

$this->collectConnectionInfos();
$this->collectStatistics();
$this->collectIndexFieldsInfo();
$this->collectIndexInspectorInfo();

return $this->getModuleTemplateResponse();
return $this->moduleTemplate->renderResponse('Index');
}

/**
Expand All @@ -76,8 +76,8 @@ public function indexAction(): ResponseInterface
public function documentsDetailsAction(string $type, int $uid, int $pageId, int $languageUid): ResponseInterface
{
$documents = $this->apacheSolrDocumentRepository->findByTypeAndPidAndUidAndLanguageId($type, $uid, $pageId, $languageUid);
$this->view->assign('documents', $documents);
return $this->getModuleTemplateResponse();
$this->moduleTemplate->assign('documents', $documents);
return $this->moduleTemplate->renderResponse('DocumentsDetails');
}

/**
Expand All @@ -95,7 +95,7 @@ protected function collectConnectionInfos(): void
$connections = $this->solrConnectionManager->getConnectionsBySite($this->selectedSite);

if (empty($connections)) {
$this->view->assign('can_not_proceed', true);
$this->moduleTemplate->assign('can_not_proceed', true);
return;
}

Expand All @@ -119,7 +119,7 @@ protected function collectConnectionInfos(): void
}
}

$this->view->assignMultiple([
$this->moduleTemplate->assignMultiple([
'site' => $this->selectedSite,
'apiKey' => Api::getApiKey(),
'connectedHosts' => $connectedHosts,
Expand Down Expand Up @@ -150,23 +150,23 @@ protected function collectStatistics(): void
/** @var StatisticsRepository $statisticsRepository */
$statisticsRepository = GeneralUtility::makeInstance(StatisticsRepository::class);

$this->view->assign(
$this->moduleTemplate->assign(
'top_search_phrases',
$statisticsRepository->getTopKeyWordsWithHits(
$siteRootPageId,
(int)($statisticsConfig['topHits.']['days'] ?? 30),
$topHitsLimit
)
);
$this->view->assign(
$this->moduleTemplate->assign(
'top_search_phrases_without_hits',
$statisticsRepository->getTopKeyWordsWithoutHits(
$siteRootPageId,
(int)($statisticsConfig['noHits.']['days'] ?? 30),
$noHitsLimit
)
);
$this->view->assign(
$this->moduleTemplate->assign(
'search_phrases_statistics',
$statisticsRepository->getSearchStatistics(
$siteRootPageId,
Expand All @@ -188,10 +188,10 @@ protected function collectStatistics(): void
$data[] = (int)$bucket['numQueries'];
}

$this->view->assign('queriesChartLabels', json_encode($labels));
$this->view->assign('queriesChartData', json_encode($data));
$this->view->assign('topHitsLimit', $topHitsLimit);
$this->view->assign('noHitsLimit', $noHitsLimit);
$this->moduleTemplate->assign('queriesChartLabels', json_encode($labels));
$this->moduleTemplate->assign('queriesChartData', json_encode($data));
$this->moduleTemplate->assign('topHitsLimit', $topHitsLimit);
$this->moduleTemplate->assign('noHitsLimit', $noHitsLimit);
}

/**
Expand Down Expand Up @@ -239,7 +239,7 @@ protected function collectIndexFieldsInfo(): void
}
$indexFieldsInfoByCorePaths[$coreAdmin->getCorePath()] = $indexFieldsInfo;
}
$this->view->assign('indexFieldsInfoByCorePaths', $indexFieldsInfoByCorePaths);
$this->moduleTemplate->assign('indexFieldsInfoByCorePaths', $indexFieldsInfoByCorePaths);
}

/**
Expand Down Expand Up @@ -273,7 +273,7 @@ protected function collectIndexInspectorInfo(): void
$documentsByCoreAndType[$languageId]['documents'] = $documentsByType;
}

$this->view->assignMultiple([
$this->moduleTemplate->assignMultiple([
'pageId' => $this->selectedPageUID,
'indexInspectorDocumentsByLanguageAndType' => $documentsByCoreAndType,
]);
Expand Down

0 comments on commit 0de5a2a

Please sign in to comment.