Skip to content
Snippets Groups Projects
Commit a57457a3 authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] Various php8 fixes

parent b66fc8de
No related branches found
No related tags found
1 merge request!38Feature upgrade to typo3 11
......@@ -102,7 +102,7 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/
public function initializeOverviewAction() {
$currentPageBrowserPage = (int) GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'];
$currentPageBrowserPage = (int) (GeneralUtility::_GP('tx_sgnews_pagebrowser')['currentPage'] ?? 0);
if ($currentPageBrowserPage > 0) {
$this->request->setArgument('currentPageBrowserPage', $currentPageBrowserPage);
}
......@@ -135,28 +135,28 @@ class OverviewController extends AbstractController {
}
// Setup settings
$startTime = (int) $this->settings['starttime'];
$endTime = (int) $this->settings['endtime'];
$newsLimit = (int) $this->settings['newsLimit'];
$startTime = (int) ($this->settings['starttime'] ?? 0);
$endTime = (int) ($this->settings['endtime'] ?? 0);
$newsLimit = (int) ($this->settings['newsLimit'] ?? 0);
$offset = $this->calculatePaginationOffset($currentPageBrowserPage, $newsLimit);
$configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$sortBy = $configurationService->getConfiguration('sortBy', $this->settings);
$sortDirection = $configurationService->getConfiguration('sortDirection', $this->settings);
$this->tagRepository->setDefaultOrderings(['sorting' => QueryInterface::ORDER_ASCENDING]);
$this->categoryRepository->setDefaultOrderings(['sorting' => QueryInterface::ORDER_ASCENDING]);
$useAllFilters = (bool) $this->settings['enableFilter'];
$isCategoryFiltered = $useAllFilters || (int) $this->settings['groupBy'] === 1;
$isTagFiltered = $useAllFilters || (int) $this->settings['groupBy'] === 2;
$useAllFilters = (bool) ($this->settings['enableFilter'] ?? false);
$isCategoryFiltered = $useAllFilters || $this->settings['groupBy'] === 1 ? 1: 0;
$isTagFiltered = $useAllFilters || $this->settings['groupBy'] === 2 ? 1: 0;
HeaderMetaDataService::addPageNumberToCanonical($currentPageBrowserPage);
// Get tag pid
$tagPid = (int) $this->settings['tagPid'];
$tagPid = (int) ($this->settings['tagPid'] ?? 0);
if (!$tagPid) {
$tagPid = $GLOBALS['TSFE']->id;
}
if ($this->settings['onlyNewsWithinThisPageSection']) {
if ($this->settings['onlyNewsWithinThisPageSection'] ?? false) {
$categories = $this->categoryRepository->findCategoriesInRootLine($GLOBALS['TSFE']->id);
$tags = $this->tagRepository->findTagsInRootLine($tagPid);
} else {
......@@ -165,7 +165,7 @@ class OverviewController extends AbstractController {
}
// Apply category restrictions
$categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'], TRUE);
$categoryRestrictions = GeneralUtility::intExplode(',', $this->settings['categoryRestrictions'] ?? '', TRUE);
if (!$isCategoryFiltered) {
$categoryRestrictions = [];
}
......@@ -191,7 +191,7 @@ class OverviewController extends AbstractController {
}
// Apply tag restrictions
$tagRestrictions = GeneralUtility::intExplode(',', $this->settings['tagRestrictions'], TRUE);
$tagRestrictions = GeneralUtility::intExplode(',', $this->settings['tagRestrictions'] ?? '', TRUE);
if (!$isTagFiltered) {
$tagRestrictions = [];
}
......@@ -205,7 +205,7 @@ class OverviewController extends AbstractController {
// Get category ids or use the one in the filter
$categoryIds = [];
if ($newsFilter['category']) {
if ($newsFilter['category'] ?? false) {
$categoryIds = [(int) $newsFilter['category']];
} elseif ($isCategoryFiltered) {
foreach ($categories as $category) {
......@@ -217,7 +217,7 @@ class OverviewController extends AbstractController {
// Get tag ids or use the one in the filter
$tagIds = [];
if ($newsFilter['tag']) {
if ($newsFilter['tag'] ?? false) {
$tagIds = [(int) $newsFilter['tag']];
} elseif ($isTagFiltered) {
foreach ($tags as $tag) {
......@@ -302,8 +302,8 @@ class OverviewController extends AbstractController {
}
// remember selection of the filter values, if any
$selectedTag = $this->tagRepository->findByUid((int) $newsFilter['tag']);
$selectedCategory = $this->categoryRepository->findByUid((int) $newsFilter['category']);
$selectedTag = $this->tagRepository->findByUid((int) ($newsFilter['tag'] ?? 0));
$selectedCategory = $this->categoryRepository->findByUid((int) ($newsFilter['category'] ?? 0));
$this->view->assign('selectedCategory', $selectedCategory);
$this->view->assign('selectedTag', $selectedTag);
$this->view->assign('tags', $tags);
......@@ -313,7 +313,7 @@ class OverviewController extends AbstractController {
$this->view->assign('allNews', $allNews);
$this->setupGridColumns();
switch ($this->settings['groupBy']) {
switch ($this->settings['groupBy'] ?? '') {
case 1:
$this->view->assign('groupBy', 'category');
$this->view->assign('categoryTabs', TRUE);
......@@ -369,8 +369,8 @@ class OverviewController extends AbstractController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
*/
protected function highlightBestFitNews(array $categoryIds = NULL, array $tagIds = NULL) {
$startTime = (int) $this->settings['starttime'];
$endTime = (int) $this->settings['endtime'];
$startTime = (int) ($this->settings['starttime'] ?? 0);
$endTime = (int) ($this->settings['endtime'] ?? 0);
/** @var News $highlightedNews */
$highlightedNews = $this->newsRepository
......
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