You are here

public static function PostViewBuilder::renderLinks in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  2. 8 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  3. 8.2 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  4. 8.3 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  5. 8.4 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  6. 8.6 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  7. 8.7 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  8. 8.8 modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  9. 10.3.x modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  10. 10.0.x modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  11. 10.1.x modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()
  12. 10.2.x modules/social_features/social_post/src/PostViewBuilder.php \Drupal\social_post\PostViewBuilder::renderLinks()

Lazy_builder callback; builds a post's links.

Parameters

string $post_entity_id: The post entity ID.

string $view_mode: The view mode in which the post entity is being viewed.

string $langcode: The language in which the post entity is being viewed.

bool $is_in_preview: Whether the post is currently being previewed.

Return value

array A renderable array representing the post links.

File

modules/social_features/social_post/src/PostViewBuilder.php, line 174

Class

PostViewBuilder
Render controller for posts.

Namespace

Drupal\social_post

Code

public static function renderLinks($post_entity_id, $view_mode, $langcode, $is_in_preview) {
  $links = [
    '#theme' => 'links',
    '#pre_render' => [
      'drupal_pre_render_links',
    ],
    '#attributes' => [
      'class' => [
        'links',
        'inline',
      ],
    ],
  ];
  if (!$is_in_preview) {
    $entity = Post::load($post_entity_id)
      ->getTranslation($langcode);
    $links['post'] = static::buildLinks($entity, $view_mode);

    // Allow other modules to alter the post links.
    $hook_context = [
      'view_mode' => $view_mode,
      'langcode' => $langcode,
    ];
    \Drupal::moduleHandler()
      ->alter('post_links', $links, $entity, $hook_context);
  }
  return $links;
}