comparison core/modules/comment/comment.api.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /**
4 * @file
5 * Hooks provided by the Comment module.
6 */
7
8 use Drupal\comment\CommentInterface;
9 use Drupal\Core\Url;
10
11 /**
12 * @addtogroup hooks
13 * @{
14 */
15
16 /**
17 * Alter the links of a comment.
18 *
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
29 *
30 * @see \Drupal\comment\CommentViewBuilder::renderLinks()
31 * @see \Drupal\comment\CommentViewBuilder::buildLinks()
32 */
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']],
37 '#links' => [
38 'comment-report' => [
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")]]),
41 ],
42 ],
43 ];
44 }
45
46 /**
47 * @} End of "addtogroup hooks".
48 */