具有方面的 RouteEnhancer 抛出 InvalidParameterException
RouteEnhancer with aspects throws InvalidParameterException
我逐字使用了 Changelog 中的示例:
我唯一改变的是 limitToPages。
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [82]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
defaultController: 'News::detail'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
routeValuePrefix: '/'
这在 9.5.4 中抛出异常:
Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match "[^/]++" ("" given) to generate a corresponding URL.
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 155
at Symfony\Component\Routing\Generator\UrlGenerator->doGenerate(array('tx_news_pi1__news' => 0), array('_controller' => 'News::detail'), array(), array(array('variable', '/', '[^/]++', 'tx_news_pi1__news', true), array('text', '/aktuelles/artikel')), array('tx_news_pi1__news' => ''), 'tx_news_pi1_0', 1, array(), array())
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 128
目前,不存在其他路由增强器。但是我在完全相同的页面上成功地使用了一个更简单的配置并且有效:
NewsDetail:
type: Extbase
limitToPages: [82]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_id}', _controller: 'News::detail', _arguments: {'news_id': 'news'} }
不确定在哪里查看以及如何最好地解决问题。我希望有人有类似的问题或者可以指出正确的方向。
检查是否为空 path_segment 是这里的问题:
select count(*) from tx_news_domain_model_news where path_segment='';
修复
如果有标题为空的新闻条目,您可能需要先删除这些条目或更新标题。
- 运行更新向导:"Updates slug field "path_segment“共EXT:news条记录”(您可能需要先在升级向导中将其标记为"undone"( BE: 升级 > 升级向导 > 运行 升级向导)
- 或手动设置tx_news_domain_model_news.path_segment
我也遇到同样的问题,问题是因为使用安装工具向导生成的 'path_segment' 有一个斜线,例如:"the-path/another-segment"
解决方案是检查 'path_segment' 中的斜杠并将其替换为另一个符号,这样请求:
SELECT uid, pid, path_segment, title FROM tx_news_domain_model_news WHERE path_segment LIKE "%/%";
并像这样更改 path_segment:"the-path_another-segment"
我逐字使用了 Changelog 中的示例:
我唯一改变的是 limitToPages。
routeEnhancers:
NewsPlugin:
type: Extbase
limitToPages: [82]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_title}', _controller: 'News::detail', _arguments: {'news_title': 'news'} }
defaultController: 'News::detail'
aspects:
news_title:
type: PersistedAliasMapper
tableName: 'tx_news_domain_model_news'
routeFieldName: 'path_segment'
routeValuePrefix: '/'
这在 9.5.4 中抛出异常:
Symfony\Component\Routing\Exception\InvalidParameterException
Parameter "tx_news_pi1__news" for route "tx_news_pi1_0" must match "[^/]++" ("" given) to generate a corresponding URL.
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 155
at Symfony\Component\Routing\Generator\UrlGenerator->doGenerate(array('tx_news_pi1__news' => 0), array('_controller' => 'News::detail'), array(), array(array('variable', '/', '[^/]++', 'tx_news_pi1__news', true), array('text', '/aktuelles/artikel')), array('tx_news_pi1__news' => ''), 'tx_news_pi1_0', 1, array(), array())
in /var/www/example/htdocs/typo3_src-9.5.4/vendor/symfony/routing/Generator/UrlGenerator.php line 128
目前,不存在其他路由增强器。但是我在完全相同的页面上成功地使用了一个更简单的配置并且有效:
NewsDetail:
type: Extbase
limitToPages: [82]
extension: News
plugin: Pi1
routes:
- { routePath: '/{news_id}', _controller: 'News::detail', _arguments: {'news_id': 'news'} }
不确定在哪里查看以及如何最好地解决问题。我希望有人有类似的问题或者可以指出正确的方向。
检查是否为空 path_segment 是这里的问题:
select count(*) from tx_news_domain_model_news where path_segment='';
修复
如果有标题为空的新闻条目,您可能需要先删除这些条目或更新标题。
- 运行更新向导:"Updates slug field "path_segment“共EXT:news条记录”(您可能需要先在升级向导中将其标记为"undone"( BE: 升级 > 升级向导 > 运行 升级向导)
- 或手动设置tx_news_domain_model_news.path_segment
我也遇到同样的问题,问题是因为使用安装工具向导生成的 'path_segment' 有一个斜线,例如:"the-path/another-segment"
解决方案是检查 'path_segment' 中的斜杠并将其替换为另一个符号,这样请求:
SELECT uid, pid, path_segment, title FROM tx_news_domain_model_news WHERE path_segment LIKE "%/%";
并像这样更改 path_segment:"the-path_another-segment"