The title resolution mechanism in TitleResolver::getTitle() was not functioning as expected when both _raw_variables and _title_arguments were defined in a route. Specifically, the method returned the static title specified in the route instead of dynamically resolving the title using the URL parameters.
Example
Route Definition:
custom_module.test_route:
path: '/test-route/{test}/{test2}'
defaults:
_controller: '\Drupal\custom_module\Controller\CustomPageController::content'
_title: 'Static title @test @test2'
_title_arguments:
'@test': 'value'
'@test2': 'value2'
requirements:
_permission: 'access content'
Before:
When the route /test-route/foo/bar was accessed with dynamic values foo and bar for {test} and {test2}, the title displayed was always:
Static title value value2
The placeholders @test and @test2 were replaced with default values from _title_arguments, ignoring the dynamic parameters.
After:
When the route /test-route/foo/bar is accessed, the title now dynamically resolves as:
Static title foo bar
Here, @test and @test2 are replaced with the actual URL parameter values foo and bar.
Resolution
The title mechanism now prioritizes URL parameters (_raw_variables) over the default values defined in _title_arguments. This ensures that titles dynamically reflect the passed URL parameters while still using defaults if parameters are absent.