Skip to content

Commit

Permalink
[BUGFIX] Custom controller actions in Typo3 11 with new return types (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
crazy252 and NamelessCoder authored Jan 12, 2022
1 parent 521b5ec commit 3cc5047
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Classes/Controller/AbstractFluxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit 3cc5047

Please sign in to comment.