I created a local action button with the following in my_module.links.action.yml:
my_module.content.action:
route_name: node.add_page
title: 'My action'
deriver: 'Drupal\my_module\Plugin\Derivative\ContentByDomainLocalActions'
appears_on:
- view.affiliated_content.page_1
Then, the local action button appears in the page admin/content/domain-content/firstdomain_local
I'd like use the argument firstdomain_local
from this URL path to pass it in my local action button.
So, I retrieve the param from \Drupal::routeMatch()
in getDerivativeDefinitions
, like in this tutorial:
class CustomLocalActions extends DeriverBase {
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives['example.action_id'] = $base_plugin_definition;
$this->derivatives['example.action_id']['title'] = "Add content";
$domain = \Drupal::routeMatch()->getParameter('arg_0');
$this->derivatives['example.action_id']['route_parameters'] = [
'domain' => $domain
];
return $this->derivatives;
}
}
But the param of the local action button is only updated after I clear the cache. I have to clear the cache each time I use different parameter value in the URL.
What's the correct way to pass dynamically this argument?