TYPO3 10 routing: How to respect TCA-Setting "uniqueInPid" in route aspect?

Viewed 223

Given TCA slug configuration:

   'slug' => [
            'label' => 'LLL:EXT:lns_games/Resources/Private/Language/locallang_db.xlf:lns_games.slug',
            'config' => [
                'type' => 'slug',
                'size' => 50,
                'generatorOptions' => [
                    'fields' => ['platform.slug', 'title'],
                    'fieldSeparator' => '/',
                    'prefixParentPageSlug' => false,
                    'postModifiers' => [
                        \Lns\LnsGames\UserFunctions\FormEngine\Slug::class . '->modifySlug'
                    ]
                ],
              
                'fallbackCharacter' => '-',
                'eval' => 'uniqueInPid',
                'default' => '',
                'behaviour' => [
                    'allowLanguageSynchronization' => 1
                ],
            ]
        ],

Results in a Slug like "pc/standard-edition". This Slug is unique on page base. The route enhancer is configured as follows:

routeEnhancers:
  GamePlugin:
    type: Extbase
    extension: LnsGames
    plugin: GamesPlugin
    routes:
      - routePath: '{game_title}'
        _controller: 'Game::show'
        _arguments:
          game_title: game
    defaultController: 'Game::show'
    requirements:
      game_title: '^[a-zA-Z0-9\-\/]+$'
    aspects:
      game_title:
        type: PersistedAliasMapper
        tableName: tx_lnsgames_domain_model_game
        routeFieldName: slug

The link build with the f:link.action ViewHelper generates the correct link to that unique url:

<f:link.action pageUid="{game.gameObject.pid}" controller="Game" action="show" arguments="{game: game.gameObject}">

{game.gameObject.uid} contains the correct object.

This results in this link: https://test.ddev.site/games/farming-simulator/pc/standard-edition

There exist other links with the same slug on other pages, like: https://test.ddev.site/games/wolfenstein/pc/standard-edition Note the "pc/standard-edition".

Following that link now results in a random object be shown, not the object which was provided as argument.

This is because the PersistedAliasMapper finds all objects with that slug and serves a random?one. It ignores the pid.

I expect the object of that special page to be shown. How can I achieve this?

0 Answers
Related