Bug #101824
closedRedirectReponse to another Controller missing controllerObjectName
0%
Description
A follow-up to Issue #91671
In TYPO3v11 the workaround with `$this->request->setControllerAliasToClassNameMapping` did the trick to allow redirecting from one Controller-Action to another.
This stopped working with the stricter Extbase RequestInterface changes of https://github.com/typo3/typo3/commit/d70a4798904ca71406bc5530a8441dea16f39300
When doing this inside a controller:
```
return (new ForwardResponse('detail'))
->withControllerName('Mycontroller')
->withExtensionName('MyExtension');
```
this will create an object that is passed to `Extbase\Mvc\Dispatcher->resolveController` which is lacking the property
```
$request->attributes->extbase->controllerObjectName
```
This one is empty, and there's no setter available. The previous workaround with `setControllerAliasToClassNameMapping` is not available to pass a FQCN into the string, and then the exception occurs within the `resolveController()` method:
```
$controllerObjectName = $request->getControllerObjectName();
// will be empty string
$controller = $this->container->get($controllerObjectName);
// Dependency Injections dies, looks for a class called ""
```
The `Services.yaml` file for auto-configuration/auto-wiring provides Extbase with the existing Controllers. The Plugins providing these Controller do show up properly everywhere else, and call also be called by Middlewares.
The easiest workaround would be to re-introduce something like `->withControllerObjectName()` to the request object, but that might bypass stronger architectural groundwork.
It should be possible though to redirect to other Controllers, and the Documentation at https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Reference/Controller/ActionController.html#forward-to-a-different-controller should reflect that.
Will try to provide a simple extension to showcase the problem next week (and hope it really isn't related to some missing Extbase-Initialization/Service-Wiring).
Updated by Garvin Hicking about 1 year ago
- Related to Bug #91671: Missing documentation?: forward to controller action of another extension added
- Related to Bug #99049: Forwarding with Extbase ForwardResponse to a different Controller only works by assigning ControllerAlias (Followup #91671) added
Updated by Garvin Hicking about 1 year ago
This was actually a misconfiguration. The target controller was not listed as a valid action/controller combination within the `::configurePlugin` call of my `ext_localconf.php`, and that was the actual reason of the controllerObjectName not getting an entry.
This wasn't fully documented, which this PR addressed: https://github.com/TYPO3-Documentation/TYPO3CMS-Reference-CoreApi/pull/3400
Issue can be closed as bogus.