Project

General

Profile

Actions

Bug #87337

closed

ExtbasePluginEnhancer does not use a custom controller configuration

Added by Guido Schmechel about 5 years ago. Updated over 4 years ago.

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

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Context
I have a standard extbase plugin. Actions are list, detail and city.

Problem
If defaultController and _controller do not match from a route, the URL will not build up cleanly. In my case, he always uses "list" to generate the URL.

Solution
When verifying each configuration in the ExtbasePluginEnhancer, the controller will not overwrite the current configuration. Only the default controller is used.

if (!empty($configuration['_controller'])) {
    $this->applyControllerActionValues(
        $configuration['_controller'],
        $originalParameters[$this->namespace]
    );
}

Route Enhancer config

routeEnhancers:
  DetailPoi:
    type: Extbase
    extension: AyacooPoi
    plugin: Poi
    routes:
      - { routePath: 'restaurant/{slug}', _controller: 'Poi::detail', _arguments: {'slug' : 'poi'} }
      - { routePath: 'stadt/{cityTitle}', _controller: 'Poi::city', _arguments: {'cityTitle' : 'city'} }
    defaultController: 'Poi::list'
    requirements:
      poi: '\d+'
      city: '\d+'
    aspects:
      slug:
        type: PersistedAliasMapper
        tableName: 'tx_ayacoopoi_domain_model_poi'
        routeFieldName: 'slug'
      cityTitle:
        type: PersistedAliasMapper
        tableName: 'tx_ayacoopoi_domain_model_poi'
        routeFieldName: 'city'

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #87668: Revert "ExtbasePluginEnhancer does not use a custom controller configuration"ClosedBenni Mack2019-02-07

Actions
Actions #1

Updated by Gerrit Code Review about 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59343

Actions #2

Updated by Alexander Grein about 5 years ago

A few notes to this route enhancer config example:
Actions #3

Updated by Gerrit Code Review about 5 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59657

Actions #4

Updated by Guido Schmechel about 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Benni Mack about 5 years ago

  • Related to Bug #87668: Revert "ExtbasePluginEnhancer does not use a custom controller configuration" added
Actions #6

Updated by Oliver Hader about 5 years ago

Base scenario

Given the following configuration

routes:
      - { routePath: 'restaurant/{slug}', _controller: 'Poi::detail', _arguments: {'slug' : 'poi'} }
      - { routePath: 'stadt/{cityTitle}', _controller: 'Poi::city', _arguments: {'cityTitle' : 'city'} }
    defaultController: 'Poi::list'

Having the following parameters &tx_ayacoopoi_poi[action]=city&... will always use Poi::list (since tx_ayacoopoi_poi[controller] is not set).

After 977ed578d04a3c2094cdad3207b5d9f86322f326

Overriding parameters with _controller (e.g. Poi::detail) values will result in overriding parameters with &tx_ayacoopoi_poi[controller]=Poi&tx_ayacoopoi_poi[action]=detail - which does not reflect the real process in comparing the originally given controller/action parameters anymore.

Approach

  • revert 977ed578d04a3c2094cdad3207b5d9f86322f326
  • reimplement change like the following
    • introduce new upgradeControllerActionValues (next to existing applyControllerActionValues) based on defaultController
    • if both parameters action and controller are empty - set both (like applyControllerActionValues)
    • if action is set, but controller is empty - just upgrade empty controller
Actions #7

Updated by Gerrit Code Review about 5 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59659

Actions #8

Updated by Gerrit Code Review about 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59659

Actions #9

Updated by Guido Schmechel about 5 years ago

  DetailPoi:
    type: Extbase
    extension: AyacooPoi
    plugin: Poi
    routes:
      - routePath: '{slug}'
        _controller: 'Poi::detail'
        _arguments:
          slug: poi
      - routePath: '{cityDb}/{postalDb}'
        _controller: 'Poi::search'
        _arguments:
          postalDb: postal
          cityDb: city
    defaultController: 'Poi::list'
    requirements:
      poi: '[0-9]+'
      city: '.*'
      postalDb: '[0-9]+'
    aspects:
      slug:
        type: PersistedAliasMapper
        tableName: tx_ayacoopoi_domain_model_poi
        routeFieldName: slug
      postalDb:
        type: PersistedAliasMapper
        tableName: tx_ayacoopoi_domain_model_postal
        routeFieldName: postal
      cityDb:
        type: PersistedAliasMapper
        tableName: tx_ayacoopoi_domain_model_postal
        routeFieldName: slug

Given there is a "search" page with a plugin/flexform with can handle list, search and detail Action. (Poi->list;Poi->detail;Poi->city;Poi->search)

Building these links via Fluid:

index.php?tx_ayacoopoi_poi[poi]=123&tx_ayacoopoi_poi[action]=detail => www.example.com/search/slugvalue-123
index.php?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne => www.example.com/search/cologne/50667

Result after PatchSet 2:

Generating links:
index.php?tx_ayacoopoi_poi[poi]=123 => www.example.com/search/slugvalue-123
index.php?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne => www.example.com/search/?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne

If you can see: The problem is the generating of the second link. There is no given action via <f:link.page> and so it use the default Controller, although the right action was set in the route. Because of that I had read out the configuration in the for loop and overwrite it.

Actions #10

Updated by Oliver Hader about 5 years ago

Guido Schmechel wrote:

[...]

Building these links via Fluid:

index.php?tx_ayacoopoi_poi[poi]=123&tx_ayacoopoi_poi[action]=detail => www.example.com/search/slugvalue-123
index.php?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne => www.example.com/search/cologne/50667

Result after PatchSet 2:

Generating links:
index.php?tx_ayacoopoi_poi[poi]=123 => www.example.com/search/slugvalue-123
index.php?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne => www.example.com/search/?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne

If you can see: The problem is the generating of the second link. There is no given action via <f:link.page> and so it use the default Controller, although the right action was set in the route. Because of that I had read out the configuration in the for loop and overwrite it.

Thanks for the explanation & I see what you're aiming for. But the 2nd URI won't work with plain Extbase (without having routing in place).

index.php?tx_ayacoopoi_poi[postal]=50667&tx_ayacoopoi_poi[city]=cologne
  • no ...[action]=search parameter is given
  • (plain) Extbase will use the default controller-action pair (as configured in ext_localconf.php) - probably PoiController::listAction

So I'm wondering why routing should introduce a new specific behavior which Extbase does not support.

Actions #11

Updated by Guido Schmechel about 5 years ago

Thanks for your feedback. You're right, the parameter is deliberately missing and in the first step I also asked for misconfiguration ;-)

For me it was a point from the documentation. I build the link with two parameters and add the "controller" and "action" over the route. So my expectation was that it would be taken from there. If this were not wished, then I wonder about the sense of the controller within the route. Maybe you can explain?

Alternatively we just have to modify the docs :-)

Actions #12

Updated by Gerrit Code Review over 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59659

Actions #13

Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62231

Actions #14

Updated by Oliver Hader over 4 years ago

  • Status changed from Under Review to Resolved
Actions #15

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF