Skip to content

Commit

Permalink
[TASK] Rector upgrade (TYPO3 11 setList)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-km2 committed Apr 18, 2023
1 parent a42d12c commit 0937374
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class ResultSetExtractor implements PropertyTypeExtractorInterface
{
private ReflectionExtractor $reflectionExtractor;
private readonly ReflectionExtractor $reflectionExtractor;

/**
* ResultSetExtractor constructor.
Expand Down
52 changes: 28 additions & 24 deletions Classes/Controller/A11yCheckController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,33 +34,22 @@ 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
*
* @var int
*/
protected $pid = 0;

/**
* BackendTemplateContainer
*
* @var BackendTemplateView
*/
protected $view;

/**
* @var IconFactory
*/
Expand All @@ -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'
);
}
Expand All @@ -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();
}
Expand All @@ -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());
}

/**
Expand All @@ -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());

Expand All @@ -164,41 +159,48 @@ public function checkAction(CheckDemand $checkDemand): ResponseInterface
'results' => $results,
'date' => new DateTime()
]);
return $this->htmlResponse();
$moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($moduleTemplate->renderContent());
}

/**
* Results action
*/
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());
}

/**
* Create menu
*/
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'];
Expand All @@ -212,7 +214,7 @@ protected function createMenu(): void
}

if ($menu instanceof Menu) {
$this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
$moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
}
}

Expand All @@ -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()) {
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

/**
* Default TypoScript
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

/**
* Plugins
Expand Down
2 changes: 1 addition & 1 deletion ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use UniWue\UwA11yCheck\Property\TypeConverter\PresetTypeConverter;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

call_user_func(function (): void {
ExtensionUtility::configurePlugin(
Expand Down
2 changes: 1 addition & 1 deletion ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use UniWue\UwA11yCheck\Controller\A11yCheckController;
defined('TYPO3_MODE') || die();
defined('TYPO3') || die();

call_user_func(function (): void {
if (TYPO3_MODE === 'BE') {
Expand Down

0 comments on commit 0937374

Please sign in to comment.