You are here

protected static function NodeViewBuilder::buildLinks in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
  2. 8.8 modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
  3. 10.3.x modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
  4. 10.0.x modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
  5. 10.2.x modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()

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

Parameters

\Drupal\node\NodeInterface $entity: The node object.

string $view_mode: A view mode identifier.

Return value

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

Overrides NodeViewBuilder::buildLinks

File

modules/social_features/social_node/src/NodeViewBuilder.php, line 16

Class

NodeViewBuilder
Provides a NodeViewBuilder that has links that work with different languages.

Namespace

Drupal\social_node

Code

protected static function buildLinks(NodeInterface $entity, $view_mode) {
  $build = parent::buildLinks($entity, $view_mode);

  // Remove the language argument from all links. It was added in Issue
  // #2149649 to solve the case where multiple translations in a single view
  // would link to the incorrect entity. However, this causes the issue in
  // Open Social that links change the interface language. Removing this
  // language argument allows the interface translation to remain the same
  // even when navigating to an entity that only exists in another language.
  foreach ($build['#links'] as &$link) {
    unset($link['language']);
  }
  return $build;
}