Missing documentation?: forward to controller action of another extension
It's maybe not really a bug, but I had a hard time to figure this out:
In an extbase-controller I forward to a controller-action of another extension. This may be not very common, but anyway.
In TYPO3 9 this worked without any problems, but not in TYPO3 10. It refused to resolve the class name of the controller to forward to.
I spent hours to understand how the dispatch-thing works, and how and when the classname of the controller is determined.
This is different in TYPO3 9, there it determines the classname by combining parts of the request (vendor, extensionname, controller, action) directly in the Request-Object's getControllerObjectName().
TYPO3 10 loads a configuration with the configuration-manager in \TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder, and passes an alias-classname-map to the request object (setControllerAliasToClassNameMapping), but this map only contains the controller classes configured in the plugin setup.
Fortunately, the setControllerAliasToClassNameMapping is public, so it's possible to override the classname-map and forward to a foreign controller:
$this->request->setControllerAliasToClassNameMapping ( ['Cloud' => 'SGPA\Sgpaclouds\Controller\CloudController'] ); $this->forward( 'navigation', 'Cloud', 'Sgpaclouds', array( 'navItems' => $navItems,'rawPrependHTML' => $this->view->render() ) );
The magic happens then in $request->setControllerName( ... ), where the class name is fetched from the map. controller->forward( ) calls $this->request->setControllerName( ... ), so the overridden map will apply there.
Maybe someone else would be glad to find this hint in the documentation.