You are here

public static function NodeViewBuilder::renderLinks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/NodeViewBuilder.php \Drupal\node\NodeViewBuilder::renderLinks()

#lazy_builder callback; builds a node's links.

Parameters

string $node_entity_id: The node entity ID.

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

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

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

Return value

array A renderable array representing the node links.

File

core/modules/node/src/NodeViewBuilder.php, line 88
Contains \Drupal\node\NodeViewBuilder.

Class

NodeViewBuilder
Render controller for nodes.

Namespace

Drupal\node

Code

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

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