NodeViewBuilder::renderLinks

public static NodeViewBuilder::renderLinks($node_entity_id, $view_mode, $langcode, $is_in_preview)

#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 83

Class

NodeViewBuilder
View builder handler 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;
}
doc_Drupal
2016-10-29 09:31:49
Comments
Leave a Comment

Please login to continue.