hook_node_links_alter(array &$links, NodeInterface $entity, array &$context)
Alter the links of a node.
array &$links: A renderable array representing the node links.
\Drupal\node\NodeInterface $entity: The node being rendered.
array &$context: Various aspects of the context in which the node links are going to be displayed, with the following keys:
\Drupal\node\NodeViewBuilder::renderLinks()
\Drupal\node\NodeViewBuilder::buildLinks()
Entity CRUD, editing, and view hooks
function hook_node_links_alter(array &$links, NodeInterface $entity, array &$context) { $links['mymodule'] = array( '#theme' => 'links__node__mymodule', '#attributes' => array('class' => array('links', 'inline')), '#links' => array( 'node-report' => array( 'title' => t('Report'), 'href' => "node/{$entity->id()}/report", 'query' => array('token' => \Drupal::getContainer()->get('csrf_token')->get("node/{$entity->id()}/report")), ), ), ); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!node!node.api.php/function/hook_node_links_alter/8.1.x