Skip to content

Commit 08a7b70

Browse files
committed
fix: TYPO3 v12 compatibility for IconSize and PHPStan backendUriBuilder guard
IconSize enum was introduced in TYPO3 v13; use class_exists() fallback to Icon::SIZE_SMALL for v12. Add PHPStan ignore for backendUriBuilder isset() guard used in test contexts. Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
1 parent 2f05cc4 commit 08a7b70

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Build/phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ parameters:
1616
-
1717
identifier: isset.property
1818
message: '#Property TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController::\$uriBuilder .* in isset\(\) is not nullable#'
19+
# BackendUriBuilder isset() guard for test contexts
20+
-
21+
identifier: isset.property
22+
message: '#Property .+TemporalCacheController::\$backendUriBuilder in isset\(\) is not nullable nor uninitialized#'
1923
# TYPO3 13+ only: IconSize enum does not exist in TYPO3 12
2024
-
2125
identifier: class.notFound

Classes/Controller/Backend/TemporalCacheController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use TYPO3\CMS\Backend\Template\ModuleTemplate;
1919
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
2020
use TYPO3\CMS\Core\Cache\CacheManager;
21+
use TYPO3\CMS\Core\Imaging\Icon;
2122
use TYPO3\CMS\Core\Imaging\IconFactory;
2223
use TYPO3\CMS\Core\Imaging\IconSize;
2324
use TYPO3\CMS\Core\Localization\LanguageService;
@@ -298,7 +299,7 @@ private function addDocHeaderButtons(ModuleTemplate $moduleTemplate, string $cur
298299
$refreshButton = $buttonBar->makeLinkButton()
299300
->setHref($this->buildModuleUri($currentAction))
300301
->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
301-
->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL))
302+
->setIcon($this->iconFactory->getIcon('actions-refresh', class_exists(IconSize::class) ? IconSize::SMALL : Icon::SIZE_SMALL))
302303
->setShowLabelText(false);
303304
$buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT, 1);
304305

@@ -316,7 +317,7 @@ private function addDocHeaderButtons(ModuleTemplate $moduleTemplate, string $cur
316317
$contentButton = $buttonBar->makeLinkButton()
317318
->setHref($this->buildModuleUri('content'))
318319
->setTitle($this->getLanguageService()->sL('LLL:EXT:nr_temporal_cache/Resources/Private/Language/locallang_mod.xlf:button.view_content'))
319-
->setIcon($this->iconFactory->getIcon('actions-document-open', IconSize::SMALL))
320+
->setIcon($this->iconFactory->getIcon('actions-document-open', class_exists(IconSize::class) ? IconSize::SMALL : Icon::SIZE_SMALL))
320321
->setShowLabelText(true);
321322
$buttonBar->addButton($contentButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
322323
break;

0 commit comments

Comments
 (0)