RouteEnhancer with aspects throws InvalidParameterException

荒凉一梦 提交于 2019-12-11 10:59:10

问题


I used the example verbatim from the Changelog:

The only thing I changed was the 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: '/'

This throws an exception in 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

Currently, no other route enhancers exist. But I successfully used a simpler configuration on that exact same page and that worked:

NewsDetail:
  type: Extbase
  limitToPages: [82]
  extension: News
  plugin: Pi1
  routes:
    - { routePath: '/{news_id}', _controller: 'News::detail', _arguments: {'news_id': 'news'} }

Not sure where to look and how best to troubleshoot. I was hoping someone had similar problem or could point me in the right direction.


回答1:


Check if empty path_segment is the problem here:

select count(*) from tx_news_domain_model_news where path_segment='';

Fix

If there are news entry with empty titles, you may want to remove these or update the title first.

  • Run update wizard: "Updates slug field "path_segment" of EXT:news records" (you may have to mark it as "undone" in Upgrade Wizard first (BE: Upgrade > Upgrade Wizard > Run Upgrade Wizard)
  • Or manually set tx_news_domain_model_news.path_segment


来源:https://stackoverflow.com/questions/54948296/routeenhancer-with-aspects-throws-invalidparameterexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!