Project

General

Profile

Actions

Bug #89451

closed

TYPO3 v9 Routing strange behaviour of routeEnhancers for controller arguments

Added by Gabriel Kaufmann / Typoworx NewMedia over 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2019-10-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
routing,routeEnhancers
Complexity:
Is Regression:
Sprint Focus:
On Location Sprint

Description

I've been trying to setup Tx-News Routing by using defaultController and routes using "_controller" argument.

My Setup looks as follows (simplyfied to detail vs list view, but in fact there are more useful/required in practice).

routeEnhancers:
  NewsPlugin:
    type: Extbase
    extension: News
    plugin: Pi1
    defaultController: 'News::list'
    routes:
      -
        routePath: '/article/{title}'
        _controller: 'News::detail'
        _arguments:
          title: news
      -
        routePath: '/{page}'
        _controller: 'News::list'
        _arguments:
          page: '@widget_0/currentPage'
    defaults:
      page: '1'
    requirements:
      page: '\d+'
    aspects:
      title:
        type: PersistedAliasMapper
        tableName: tx_news_domain_model_news
        routeFieldName: path_segment
      page:
        type: StaticRangeMapper
        start: '1'
        end: '999'

As you may notice each route defined in routes-section has cleanly declared it's own _controller-argument. Additionally there is defined defaultController for Controller-Action 'News::list' (I assume it's ment to be a fallback if no _controller-argument is given?!).

There have several configurations been tested mentioned in YAML-Routing documentations and Tx-News docs. None of them was able to work correctly.

Expectations:
I would expect that URI-Builder will use _controller-argument if given and defaultController only if there is no _controller-argument in the given route.

Current Results
Using defaultController with 'News::list' only the Pagination speaking URLs work! The News-Detail Links are not working (despite they are pointing to their correct Controller-Argument using _controller in their route-section).

Switching defaultController to 'News::detail' it's simply the same inverted. News-List pagination links do not result into a speaking-url. The detail-links work fine.

Conclusion
I think this must be a misbehaving. Currently the only workaround I could think of would be to use separate routeEnhancer one for each Controller-Action each pointing to defaultController to their controller-action (which makes _controller-argument in routes needless).

The correct behaving would be to primarily use _controller-argument for URL-Builder and URL-Resolver and if none is given using defaultController as fallback.

I think this is not a bug in http-foundation, but in YAML-Parsing or Routing-Wrappers around http-foundation.

Actions

Also available in: Atom PDF