From 3cc50474d8504bbbf2b043410b04110882332b69 Mon Sep 17 00:00:00 2001 From: crazy252 Date: Wed, 12 Jan 2022 11:01:18 +0100 Subject: [PATCH] [BUGFIX] Custom controller actions in Typo3 11 with new return types (#1911) * [BUGFIX] Custom controller actions handling in v11 * [TASK] Use version_compare for version check * [TASK] Remove version number utility * [TASK] Added version detection from commit NamelessCoder Co-authored-by: Claus Due --- Classes/Controller/AbstractFluxController.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Classes/Controller/AbstractFluxController.php b/Classes/Controller/AbstractFluxController.php index 0e67b9499..5ecea73e1 100644 --- a/Classes/Controller/AbstractFluxController.php +++ b/Classes/Controller/AbstractFluxController.php @@ -17,6 +17,8 @@ use FluidTYPO3\Flux\Utility\ExtensionNamingUtility; use FluidTYPO3\Flux\Utility\RecursiveArrayUtility; use FluidTYPO3\Flux\ViewHelpers\FormViewHelper; +use TYPO3\CMS\Core\Information\Typo3Version; +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -427,12 +429,19 @@ protected function callSubControllerAction( $this->request->setControllerExtensionName($extensionName); $this->request->setControllerActionName($controllerActionName); $potentialControllerInstance = $this->objectManager->get($controllerClassName); + if (isset($this->responseFactory)) { $response = $this->responseFactory->createResponse(); } else { $response = $this->objectManager->get(Response::class); } + if (class_exists(Typo3Version::class)) { + $version = GeneralUtility::makeInstance(Typo3Version::class)->getVersion(); + } else { + $version = ExtensionManagementUtility::getExtensionVersion('core'); + } + try { HookHandler::trigger( HookHandler::CONTROLLER_BEFORE_REQUEST, @@ -444,7 +453,12 @@ protected function callSubControllerAction( 'controllerActionName' => $controllerActionName ] ); - $potentialControllerInstance->processRequest($this->request, $response); + + if (version_compare($version, 11, '<')) { + $potentialControllerInstance->processRequest($this->request, $response); + } else { + $response = $potentialControllerInstance->processRequest($this->request); + } } catch (StopActionException $error) { // intentionally left blank }