Project

General

Profile

Actions

Bug #91671

closed

Missing documentation?: forward to controller action of another extension

Added by This Mächler almost 4 years ago. Updated 8 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
2020-06-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
extbase controller forward class map alias
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

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.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #101824: RedirectReponse to another Controller missing controllerObjectNameClosed2023-09-01

Actions
Actions

Also available in: Atom PDF