Bug #97281
closedRouteEnhancer for two extbase plugins using the same actions can't be resolved correctly
0%
Description
Bug description:
There seems to be a bug with the Sites Config for Extbase extensions if you have two plugins that use the same actions. I don't think it only occurs in TYPO3 10 but also in other versions.
- If the plugin for the show action is first in the config, it works, but the other plugin only shows the list action despite a correct link.
- If the other plugin (the one with the list and show) comes first, the show action in this plugin works, but the other plugin shows an error because the record is missing.
The links are built correctly in both cases, but do not seem to be resolved correctly. The attribute "plugin" is apparently only taken into account for generating the URLs, but not for resolving them. The system always seems to use the first entry for the combination of extension and action, even if it does not match the plugin that is used on the page.
It only works if limitToPages is used in the configuration of the first plugin, but this is not always an option.
Example Config:
Detail Plugin:
ExampleDetailPlugin:
type: Extbase
extension: Example
plugin: ExampleDetail
routes:
-
routePath: '/{record}'
_controller: 'Example::show'
_arguments:
record: record
requirements:
record: '^[a-zA-Z0-9].*$'
aspects:
record:
type: PersistedAliasMapper
tableName: tx_example_domain_model_record
routeFieldName: slug
List Plugin:
ExampleListPlugin:
type: Extbase
extension: Example
plugin: ExampleList
routes:
-
routePath: '/'
_controller: 'Example::list'
-
routePath: '/{record}'
_controller: 'Example::show'
_arguments:
record: record
requirements:
record: '^[a-zA-Z0-9].*$'
aspects:
record:
type: PersistedAliasMapper
tableName: tx_example_domain_model_record
routeFieldName: slug
A possible solution maybe:
Perhaps it would be possible to find the record in the database using the slug and then search the page for a plugin in tt_content that is part of the extension to which the record belongs. If there is one you could resolve the url for that plugin. Otherwise you could do the same as you do now.
Thank you for reading!
Updated by Stefan Bürk over 2 years ago
To answer on your possible solution:
Nope, that's not possible. These thinks happens in different layers, and eventually retrieving all (nested) elements for different "pages" in the routing process would be a worse solution.
So, this is not a bug in the core. This is an issue of "ambigous" configuration on your side. Thus the solution is to configure unabigous route configuration on your side.
Given your "example configuration".
add prefix to the routepaths to distingish this:
ExampleDetailPlugin:
type: Extbase
extension: Example
plugin: ExampleDetail
routes:
-
routePath: '/detail/{record}'
_controller: 'Example::show'
_arguments:
record: record
requirements:
record: '^[a-zA-Z0-9].*$'
aspects:
record:
type: PersistedAliasMapper
tableName: tx_example_domain_model_record
routeFieldName: slug
ExampleListPlugin:
type: Extbase
extension: Example
plugin: ExampleList
routes:
-
routePath: '/'
_controller: 'Example::list'
-
routePath: '/show/{record}'
_controller: 'Example::show'
_arguments:
record: record
requirements:
record: '^[a-zA-Z0-9].*$'
aspects:
record:
type: PersistedAliasMapper
tableName: tx_example_domain_model_record
routeFieldName: slug
Otherwise limit it to pages, as you already wrote.
To answer eventually back-questioning:
On the "encoding" / "link generation" it is clear which plugin to use, and the record. That's the reason why it is build. On the other hand, you would never see it.
Further you wrote the same table name for both plugins.
And then I do not get why are you having two plugins which uses the same model an action - only that one has a default one connected ??
Updated by Oliver Hader about 2 years ago
- Status changed from New to Rejected
Closing this issue, Stefan outlined a potential & correct solution.
There is no other way to resolve that ambiguity.