You are here

protected static function PostViewBuilder::buildLinks in Open Social 10.2.x

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

Build the default links (Read more) for a post.

Parameters

\Drupal\social_post\Entity\Post $entity: The post object.

string $view_mode: A view mode identifier.

Return value

array An array that can be processed by drupal_pre_render_links().

1 call to PostViewBuilder::buildLinks()
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/src/PostViewBuilder.php, line 206

Class

PostViewBuilder
Render controller for posts.

Namespace

Drupal\social_post

Code

protected static function buildLinks(Post $entity, $view_mode) {
  $links = [];
  if ($entity
    ->access('update') && $entity
    ->hasLinkTemplate('edit-form')) {
    $links['edit'] = [
      'title' => t('Edit'),
      'weight' => 10,
      'url' => $entity
        ->toUrl('edit-form'),
      'query' => [
        'destination' => \Drupal::destination()
          ->get(),
      ],
    ];
  }
  if ($entity
    ->access('delete') && $entity
    ->hasLinkTemplate('delete-form')) {
    $links['delete'] = [
      'title' => t('Delete'),
      'weight' => 100,
      'url' => $entity
        ->toUrl('delete-form'),
      'query' => [
        'destination' => \Drupal::destination()
          ->get(),
      ],
    ];
  }
  return [
    '#theme' => 'links',
    '#links' => $links,
    '#attributes' => [
      'class' => [
        'links',
        'inline',
      ],
    ],
  ];
}