Skip to content
Snippets Groups Projects
Verified Commit f0600927 authored by Stefan Galinski's avatar Stefan Galinski :video_game: Committed by Kevin Ditscheid
Browse files

[BUGFIX] Fix TYPO3 11 compatibility, Fix missing doktype check for news

(cherry picked from commit d06f261f)
parent 3d873fff
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,7 @@ use TYPO3\CMS\Backend\Controller\PageLayoutController;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageRendererResolver;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -38,22 +39,17 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*
*/
class CategoryWarningDrawer {
/**
* @var LanguageService
*/
protected $languageService;
public function __construct(LanguageService $languageService) {
$this->languageService = $languageService;
}
/**
* @param array|NULL $params
* @param PageLayoutController|NULL $parentObj
* @return string
* @throws \Doctrine\DBAL\Driver\Exception
* @throws \Doctrine\DBAL\Driver\Exception|\Doctrine\DBAL\DBALException
*/
public function render(array $params = NULL, PageLayoutController $parentObj = NULL): string {
if (!$parentObj || $parentObj->pageinfo['doktype'] !== 116) {
return '';
}
$parentPage = $parentObj->pageinfo['pid'];
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
......@@ -66,19 +62,21 @@ class CategoryWarningDrawer {
)
)->execute()
->fetchOne();
if ($parentDoktype === Category::DOK_TYPE_CATEGORY) {
return '';
}
$languageService = GeneralUtility::makeInstance(LanguageService::class);
$message = GeneralUtility::makeInstance(
FlashMessage::class,
$this->languageService->sL(
$languageService->sL(
'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:categoryErrorMessage'
),
$this->languageService->sL(
$languageService->sL(
'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:categoryErrorMessageHeader'
),
FlashMessage::ERROR,
AbstractMessage::ERROR,
TRUE
);
return GeneralUtility::makeInstance(FlashMessageRendererResolver::class)
......
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