I want to have tabs but since they need to be dynamic I am making use of local tasks. In the class extending `DeriverBase` I have written the following function:
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = array();
foreach ($this->moduleFormatManager->getDefinitions() as $key => $definition) {
$this->derivatives[$key]['title'] = $definition['title'];
$this->derivatives[$key]['route_parameters'] = array('module_format' => $key);
$this->derivatives[$key]['route_name'] = 'module.format_configure_' . $key;
if($key == 'xyz') {
$key = 'newkey';
$this->derivatives[$key]['title'] = 'newkey';
$this->derivatives[$key]['route_name'] = 'module.newkey';
$this->derivatives[$key]['parent_id'] = "module.format_configure:xyz";
}
}
foreach ($this->derivatives as &$entry) {
$entry += $base_plugin_definition;
}
return $this->derivatives;
}
In the above code, a tab for each key is being generated: my problem is in the if condition. In the if condition I am trying to generate a sub tab for a particular type of tab by declaring `parent_id`. But the code doesn't work for me.
What changes should I introduce in order to make it work? I used this link https://www.drupal.org/node/2122253 to learn about local tasks.
Update: My module.links.tasks.yml file looks like this:
`module.format_configure:
title: 'Configuration'
base_route: module.configure
tab_root_id: module.configure
deriver: 'path to deriver'`
All the mentioned routes have been declared in *.routing.yml file.