You are here

function hook_post_links_alter in Open Social 8.9

Same name and namespace in other branches
  1. 8.5 modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  2. 8.6 modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  3. 8.7 modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  4. 8.8 modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  5. 10.3.x modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  6. 10.0.x modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  7. 10.1.x modules/social_features/social_post/social_post.api.php \hook_post_links_alter()
  8. 10.2.x modules/social_features/social_post/social_post.api.php \hook_post_links_alter()

Alter the links of a post.

Parameters

array &$links: A renderable array representing the post links.

\Drupal\social_post\Entity\PostInterface $entity: The post being rendered.

array &$context: Various aspects of the context in which the post links are going to be displayed, with the following keys:

  • 'view_mode': the view mode in which the post is being viewed
  • 'langcode': the language in which the post is being viewed.

See also

\Drupal\social_post\PostViewBuilder::renderLinks()

\Drupal\social_post\PostViewBuilder::buildLinks()

1 function implements hook_post_links_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

social_content_report_post_links_alter in modules/social_features/social_content_report/social_content_report.module
Implements hook_post_links_alter().
1 invocation of hook_post_links_alter()
PostViewBuilder::renderLinks in modules/social_features/social_post/src/PostViewBuilder.php
Lazy_builder callback; builds a post's links.

File

modules/social_features/social_post/social_post.api.php, line 58
Hooks provided by the Social Post module.

Code

function hook_post_links_alter(array &$links, PostInterface $entity, array &$context) {
  $links['mymodule'] = [
    '#theme' => 'links__post__mymodule',
    '#attributes' => [
      'class' => [
        'links',
        'inline',
      ],
    ],
    '#links' => [
      'post-report' => [
        'title' => t('Report'),
        'url' => Url::fromRoute('post_test.report', [
          'post' => $entity
            ->id(),
        ], [
          'query' => [
            'token' => \Drupal::getContainer()
              ->get('csrf_token')
              ->get("post/{$entity->id()}/report"),
          ],
        ]),
      ],
    ],
  ];
}