#106174Can not create BE links between Extbase modules using f:link.action view-helper if enableNamespacedArgumentsForBackend is disabled
Description
I’m in a backend Extbase AccountingModule and try to link with ‘‘f:link.action()’‘ from a list-view of invoices to another BE module named UserModule (to show the related user of an invoice):
<f:link.action controller="Backend\UserModule\User" action="show" arguments="{user: invoice.user.uid}"
pluginName="vendor_MyCoreUser" class="btn btn-default btn-sm" title="Show user">
<core:icon identifier="actions-view-page"/>
</f:link.action>
The problem is, that the URL is never generated, only the icon file is shown.
During debugging we found the issue in Extbase’s ‘‘UriBuilder’‘, because it derives a route-identifier for the current route (AccountingModule), which results in a wrong route-identifier construction with the passed view-helper arguments:
UriBuilder line 620: get the current route-identifier
if (($route = $request?->getAttribute('route')) instanceof Route) {
$arguments['route'] = $route->getOption('_identifier');
}
UriBuilder line 628: The variables having the following values:
$routeIdentifier: String 'vendor_MyCoreAccounting.Backend\AccountingModule\Invoice_list'
$arguments: Array
(
[user] => 123
[action] => show
[controller] => Backend\UserModule\User
)
UriBuilder line 637: Because the route contains a dot, the route is exploded to get the prefix-part of the CURRENT route identifier:
$routeIdentifier: String 'vendor_MyCoreAccounting'
UriBuilder line 642: The wrong current route-prefix is now combined with the given view-helper $arguments for the other module:
$routeIdentifier: String 'vendor_MyCoreAccounting.Backend\UserModule\User_show'
And this is the issue, because this route-identifier does not exists! The expected value would be ‘‘vendor_MyCoreUser.Backend\UserModule\User_show’‘, like given to the view-helper in “pluginName” argument.
We thought, it might work if the “enableNamespacedArgumentsForBackend” feature is enabled for both modules, but the issue is similar: yes, with this feature enabled the URL is generated at least, BUT not working, because its linking still to the wrong module (but has the correct URL parameter):
’‘https://project.ddev.site/typo3/module/vendor/MyCoreAccounting?tx_mycore_mycoreuser%5Baction%5D=show&tx_mycore_mycoreuser%5Bcontroller%5D=Backend%5CUserModule%5CUser&token=…’‘ (expected URL: ‘’…/module/vendor/MyCoreUser?…’‘)
How to fix the issue:
If “enableNamespacedArgumentsForBackend” feature is disabled (default), we simply pass the ‘’$pluginName’‘ as “route” to ‘’$prefixedControllerArguments’‘:
$prefixedControllerArguments = $controllerArguments;
$prefixedControllerArguments['route'] = $pluginName; // FIX (added in line 538 of UriBuilder)
Later in ‘’$this->buildBackendUri()’‘ method, this “route” value overwrites the route-identifier which was derived from the ‘’$request’‘ using ‘‘array_replace_recursive()’‘, and that fixes the issue.
From my understanding there shouldn’t be any side-effects with this solution, since ‘’$pluginName’‘ is always set by ‘’$this->request->getPluginName()’‘ if not given (null), and this value is always equivalent with the dot-prefix of ‘’$request?->getAttribute(‘route’)’‘ of the current route.