5 * Hooks provided by the Comment module.
8 use Drupal\comment\CommentInterface;
17 * Alter the links of a comment.
19 * @param array &$links
20 * A renderable array representing the comment links.
21 * @param \Drupal\comment\CommentInterface $entity
22 * The comment being rendered.
23 * @param array &$context
24 * Various aspects of the context in which the comment links are going to be
25 * displayed, with the following keys:
26 * - 'view_mode': the view mode in which the comment is being viewed
27 * - 'langcode': the language in which the comment is being viewed
28 * - 'commented_entity': the entity to which the comment is attached
30 * @see \Drupal\comment\CommentViewBuilder::renderLinks()
31 * @see \Drupal\comment\CommentViewBuilder::buildLinks()
33 function hook_comment_links_alter(array &$links, CommentInterface $entity, array &$context) {
34 $links['mymodule'] = [
35 '#theme' => 'links__comment__mymodule',
36 '#attributes' => ['class' => ['links', 'inline']],
39 'title' => t('Report'),
40 'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]),
47 * @} End of "addtogroup hooks".