I have a route set up with a slug accepting taxonomy terms (routing.yml
):
example.column:
path: '/column/{taxonomy_term}'
I would like to add (secondary, although that's not important) local task tabs on a page, one for each possible term of the vocabulary used (links.task.yml
):
example.column_list:
deriver: 'Drupal\example\Plugin\Derivative\ColumnTasks'
parent_id: example.parent
The deriver is pretty straightforward and simple and mentioned in a few docs on drupal.org, the relevant part is:
foreach ($columns as $column) {
$route_name = 'example.column';
$this->derivatives[$route_name] = [
'title' => $column->getName(),
'route_name' => $route_name,
'route_parameters' => ['taxonomy_term' => $column->id()],
'parent_id' => 'example.parent',
] + $base_plugin_definition;
}
The problem is that this code, obviously, doesn't generate more than one tab because all go to the same $route_name
. But I'm not allowed to use any other route name (suffixing it with the term, for instance) because it complains about a non-existent route then.
Do I have any other solution than to generate all the routes separately, using a _route_callback
? This would somehow feel wrong, going against the reason for the existence of slugs in the first place.