/** * Implements hook_node_links_alter(). */ function {{ machine_name }}_node_links_alter(array &$links, NodeInterface $entity, array &$context) { $links['mymodule'] = [ '#theme' => 'links__node__mymodule', '#attributes' => ['class' => ['links', 'inline']], '#links' => [ 'node-report' => [ 'title' => t('Report'), 'url' => Url::fromRoute('node_test.report', ['node' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("node/{$entity->id()}/report")]]), ], ], ]; }