Bug #89263
closedTCEMAIN.preview doesn't work for routed controller with empty arguments
0%
Description
It's said in the subject and it has nothing to do with the news extension.
Example:
Site configuration (yaml):
routeEnhancers: NewsPlugin: type: Extbase extension: News plugin: Pi1 routes: - routePath: '/news/{news_title}' _controller: 'News::detail' _arguments: news_title: news aspects: news_title: type: PersistedAliasMapper tableName: tx_news_domain_model_news routeFieldName: path_segment
Page tsconfig:
TCEMAIN{ preview { tx_news_domain_model_news { useCacheHash = 1 previewPageId = 123 useDefaultLanguageRecord = 0 fieldToParameterMap { uid = tx_news_pi1[news_preview] } additionalGetParameters { tx_news_pi1.controller = News tx_news_pi1.action = detail } } } }
When I will access the preview, it gives the following error:
(1/1) Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match "[^/]++" ("" given) to generate a corresponding URL.
Because of having no tx_news_pi1[news] variable, the url cannot be generated. It seems to be required always.
I tried to set the variable like this "{news_title?}" in the yaml configuration, wich is not respected (https://symfony.com/doc/current/routing.html#optional-parameters).
Also I found an option "strict_requirements", which will generate the url, when I set it in the core of the vendor (defined in vendor/symfony/routing/Route.php, set in vendor/symfony/routing/Router.php).
In the core of Typo3 the routing has no option, which I can set ("strict_requirements" option or the variable "{news_title?}" in yaml).
To set the news parameter like this "TCEMAIN.preview.tx_news_domain_model_news.additionalGetParameters.tx_news_pi1.news = " will produce an error too.