I have a legacy extension with a plugin that's handled in MyPluginController, which extends TYPO3\CMS\Frontend\Plugin\AbstractPlugin
.
The plugin is registered as a USER_INT
content object:
plugin.tx_myext_pi1 = USER_INT
plugin.tx_myext_pi1.userFunc = Foo\MyExt\Controller\MyPluginController->main
The render() method of both the UserContentObject
and UserInternalContentObject
(which handle USER + USER_INT) return a string (i.e. the rendered output of your plugin).
There are a few instances in my controller, where a redirect is required (e.g. to call the payment page of a remote payment gateway). So far this was done with HttpUtility::redirect()
, but this method has been marked as deprecated as of V11.3 [1].
The deprecation note says that a PSR-7 compliant response object should be used instead.
The suggested migration strategies are to either return a Response object directly or throw a PropagateResponseException
. But the latter is considered an "intermediate solution only".
If I return a PSR-7 Response directly, it (predictably) results in an exception as we already know that a string is expected:
Object of class TYPO3\CMS\Core\Http\RedirectResponse could not be converted to string
So what can you do? Is there a sustainable way to issue an HTTP redirect in this scenario? And if not, what else can you do? One could return a dummy page and work with an onload Javascript redirect or try a redirect meta header in HTML. But these are all pretty ugly approaches IMHO.