protected static function NodeViewBuilder::buildLinks in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
- 8.8 modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
- 10.3.x modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
- 10.1.x modules/social_features/social_node/src/NodeViewBuilder.php \Drupal\social_node\NodeViewBuilder::buildLinks()
- 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_nodeCode
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;
}