TYPO3 10 路由 - 参数为空

TYPO3 10 Routing - Parameters are empty

- 1 年零 8 个月后,我们正在尝试更新到 TYPO3 10,然后再更新到 TYPO3 11。如您所见,站点配置在 typo3 9 上运行得很好,但现在它不会了。

routeEnhancers:
  Werbemittelshop:
    type: Extbase
    extension: Mwwerbemittelshop
    plugin: Mwwerbemittelshop
    routes:
      -
        routePath: '/{categoryname}/{categoryname2}/{categoryname3}'
        _controller: 'MwWsCategories::category'
        _arguments:
          categoryname: mwWsCategory
          categoryname2: mwWsCategory2
          categoryname3: mwWsCategory3
      -
        routePath: '/{productname}'
        _controller: 'MwWsCategories::product'
        _arguments:
          productname: mwWsProduct
    defaults:
      categoryname2: ''
      categoryname3: ''
    defaultController: 'MwWsCategories::category'
    aspects:
      categoryname:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
        routeFieldName: slug
      categoryname2:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
        routeFieldName: slug
      categoryname3:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
        routeFieldName: slug
      productname:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwsproducts
        routeFieldName: slug

“productname”完全符合预期。它是一个可读的 url 示例。de/test123 并且它使用控制器的正确操作。

“categoryname2”和“categoryname3”是问题所在。如果我打开 example.de/category1/ 它有效,但如果我添加第二个或第三个参数,我的参数为空(example.de/category1/category2),我不明白它。

/**
     * action category
     *
     * @param \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory
     * @param \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory2
     * @param \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory3
     * @return void
     */
    public function categoryAction(
        \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory = null, 
        \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory2 = null, 
        \MwWerbemittelshop\Mwwerbemittelshop\Domain\Model\MwWsCategories $mwWsCategory3 = null
    )
    {
        var_dump($this->request->getArguments());
        var_dump($mwWsCategory);
        exit;

你们有人能找出我的错误吗?我尝试了很多版本,但没有任何效果。如果您有任何疑问或需要更多代码,请提出要求。

提前致谢。

我不能说为什么,但如果您将每个案例定义为自己的路线,它就会起作用:

  • 一个类别
  • 两类
  • 三类
  • 产品名称

...以及没有任何给定参数(或默认值!)的默认情况:

routeEnhancers:
  Werbemittelshop:
    type: Extbase
    extension: Mwwerbemittelshop
    plugin: Mwwerbemittelshop
    routes:
      -
        routePath: '/{productname}'
        _controller: 'MwWsCategories::product'
        _arguments:
          productname: mwWsProduct
      -
        routePath: '/{categoryname}'
        _controller: 'MwWsCategories::category'
        _arguments:
          categoryname: mwWsCategory
      -
        routePath: '/{categoryname}/{categoryname2}'
        _controller: 'MwWsCategories::category'
        _arguments:
          categoryname: mwWsCategory
          categoryname2: mwWsCategory2
      -
        routePath: '/{categoryname}/{categoryname2}/{categoryname3}'
        _controller: 'MwWsCategories::category'
        _arguments:
          categoryname: mwWsCategory
          categoryname2: mwWsCategory2
          categoryname3: mwWsCategory3
    defaultController: 'MwWsCategories::category'
    aspects:
      categoryname:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
        routeFieldName: slug
      categoryname2:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
        routeFieldName: slug
      categoryname3:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwscategories
        routeFieldName: slug
      productname:
        type: PersistedAliasMapper
        tableName: tx_mwwerbemittelshop_domain_model_mwwsproducts
        routeFieldName: slug