Skip to content
Snippets Groups Projects

Task apply language visibility to the news

Merged Fabian Galinski requested to merge task_apply_language_visibility_to_the_news into master
Files
12
@@ -55,10 +55,12 @@ class LatestController extends AbstractController {
/**
* Renders the news overview
*
* @param array $newsMetaData
* @param int $offset
* @return void
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
public function indexAction() {
public function indexAction(array $newsMetaData = [], $offset = 0) {
$limit = ((int) $this->settings['limit']);
$limit = ($limit < 1 ? 1 : $limit);
@@ -69,10 +71,9 @@ class LatestController extends AbstractController {
}
$latestNewsEntries = $this->newsRepository->findLastUpdatedOrHighlightedNewsByCategories(
$limit, FALSE, $categoryUids, 0, TRUE, $this->settings['sortBy'], $tagUids
$limit, FALSE, $categoryUids, $offset, TRUE, $this->settings['sortBy'], $tagUids
);
$newsMetaData = [];
$categories = [];
foreach ($latestNewsEntries as $latestNewsEntry) {
/** @var News $latestNewsEntry */
@@ -88,8 +89,25 @@ class LatestController extends AbstractController {
}
$newsMetaData[] = $this->getMetaDataForNews($latestNewsEntry, $category);
// Make sure, that the amount is the same as the configured limit.
if (count($newsMetaData) >= $limit) {
break;
}
}
// Redo this function, until $newsMetaData gets the $limit. Needed because of languagevisibility.
if (count($newsMetaData) < $limit) {
$offset += $limit;
$maxCount = $this->newsRepository->getCountOfLastUpdatedOrHighlightedNewsByCategories(
FALSE, $categoryUids, TRUE, $this->settings['sortBy'], $tagUids
);
if ($offset < $maxCount) {
$this->indexAction($newsMetaData, $offset);
return;
}
}
$this->view->assign('newsMetaData', $newsMetaData);
}
}
Loading