Skip to content
Snippets Groups Projects
Commit d06f261f authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

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

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