From 0937374018a3eb7ef8dd5c86a303dc332f75102e Mon Sep 17 00:00:00 2001 From: David Brauer Date: Tue, 18 Apr 2023 08:52:51 +0200 Subject: [PATCH] [TASK] Rector upgrade (TYPO3 11 setList) --- .../Extractor/ResultSetExtractor.php | 2 +- Classes/Controller/A11yCheckController.php | 52 ++++++++++--------- Configuration/TCA/Overrides/sys_template.php | 2 +- Configuration/TCA/Overrides/tt_content.php | 2 +- ext_localconf.php | 2 +- ext_tables.php | 2 +- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php b/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php index ff082d4..ab531ab 100644 --- a/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php +++ b/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php @@ -14,7 +14,7 @@ */ class ResultSetExtractor implements PropertyTypeExtractorInterface { - private ReflectionExtractor $reflectionExtractor; + private readonly ReflectionExtractor $reflectionExtractor; /** * ResultSetExtractor constructor. diff --git a/Classes/Controller/A11yCheckController.php b/Classes/Controller/A11yCheckController.php index c738e0a..e59c169 100644 --- a/Classes/Controller/A11yCheckController.php +++ b/Classes/Controller/A11yCheckController.php @@ -2,6 +2,7 @@ namespace UniWue\UwA11yCheck\Controller; +use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Annotation\IgnoreValidation; use Psr\Http\Message\ResponseInterface; @@ -33,19 +34,15 @@ class A11yCheckController extends ActionController * @var PresetService */ protected $presetService; + public function __construct(private ModuleTemplateFactory $moduleTemplateFactory) + { + } public function injectPresetService(PresetService $presetService): void { $this->presetService = $presetService; } - /** - * Backend Template Container - * - * @var string - */ - protected $defaultViewObjectName = BackendTemplateView::class; - /** * The current page uid * @@ -53,13 +50,6 @@ public function injectPresetService(PresetService $presetService): void */ protected $pid = 0; - /** - * BackendTemplateContainer - * - * @var BackendTemplateView - */ - protected $view; - /** * @var IconFactory */ @@ -75,15 +65,16 @@ public function injectPresetService(PresetService $presetService): void */ protected function initializeView(ViewInterface $view): void { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); /** @var BackendTemplateView $view */ parent::initializeView($view); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); $this->resultsService = $this->objectManager->get(ResultsService::class); - $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); + $moduleTemplate->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); if ($view instanceof BackendTemplateView) { - $view->getModuleTemplate()->getPageRenderer()->addCssFile( + $moduleTemplate->getPageRenderer()->addCssFile( 'EXT:uw_a11y_check/Resources/Public/Css/a11y_check.css' ); } @@ -106,8 +97,9 @@ public function initializeAction(): void * @param CheckDemand $checkDemand * @IgnoreValidation("checkDemand") */ - public function indexAction($checkDemand = null): void + public function indexAction($checkDemand = null): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); if ($checkDemand === null) { $checkDemand = new CheckDemand(); } @@ -130,6 +122,8 @@ public function indexAction($checkDemand = null): void 'levelSelectorOptions' => $this->getLevelSelectorOptions(), 'savedResultsCount' => $this->resultsService->getSavedResultsCount($this->pid), ]); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** @@ -156,6 +150,7 @@ public function initializeCheckAction(): void */ public function checkAction(CheckDemand $checkDemand): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $preset = $checkDemand->getPreset(); $results = $preset->executeTestSuiteByPageUid($this->pid, $checkDemand->getLevel()); @@ -164,7 +159,8 @@ public function checkAction(CheckDemand $checkDemand): ResponseInterface 'results' => $results, 'date' => new DateTime() ]); - return $this->htmlResponse(); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** @@ -172,22 +168,27 @@ public function checkAction(CheckDemand $checkDemand): ResponseInterface */ public function resultsAction(): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $this->createAcknowledgeButton($this->pid); $resultsArray = $this->resultsService->getResultsArrayByPid($this->pid); $this->view->assignMultiple([ 'resultsArray' => $resultsArray ]); - return $this->htmlResponse(); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** * AcknowledgeResult Action */ - public function acknowledgeResultAction(int $pageUid): void + public function acknowledgeResultAction(int $pageUid): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $this->resultsService->deleteSavedResults($pageUid); $this->redirect('index'); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** @@ -195,10 +196,11 @@ public function acknowledgeResultAction(int $pageUid): void */ protected function createMenu(): void { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $uriBuilder = $this->objectManager->get(UriBuilder::class); $uriBuilder->setRequest($this->request); - $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); + $menu = $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); $menu->setIdentifier('uw_a11y_check'); $actions = ['index', 'results']; @@ -212,7 +214,7 @@ protected function createMenu(): void } if ($menu instanceof Menu) { - $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu); + $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu); } } @@ -221,7 +223,8 @@ protected function createMenu(): void */ protected function createDefaultButtons(): void { - $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); + $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar(); // Shortcut if ($this->getBackendUser()->mayMakeShortcut()) { @@ -238,10 +241,11 @@ protected function createDefaultButtons(): void */ protected function createAcknowledgeButton(int $pid): void { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $uriBuilder = $this->objectManager->get(UriBuilder::class); $uriBuilder->setRequest($this->request); - $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); + $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar(); $title = $this->getLanguageService()->sL(self::LANG_LOCAL . 'labels.acknowledgeResults'); $button = $buttonBar->makeLinkButton(); diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 28d96b5..0ce26eb 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,7 +1,7 @@