protected static NodeViewBuilder::buildLinks(NodeInterface $entity, $view_mode)
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().
File
- core/modules/node/src/NodeViewBuilder.php, line 115
Class
- NodeViewBuilder
- View builder handler for nodes.
Namespace
Drupal\node
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | protected static function buildLinks(NodeInterface $entity , $view_mode ) { $links = array (); // Always display a read more link on teasers because we have no way // to know when a teaser view is different than a full view. if ( $view_mode == 'teaser' ) { $node_title_stripped = strip_tags ( $entity ->label()); $links [ 'node-readmore' ] = array ( 'title' => t( 'Read more<span class="visually-hidden"> about @title</span>' , array ( '@title' => $node_title_stripped , )), 'url' => $entity ->urlInfo(), 'language' => $entity ->language(), 'attributes' => array ( 'rel' => 'tag' , 'title' => $node_title_stripped , ), ); } return array ( '#theme' => 'links__node__node' , '#links' => $links , '#attributes' => array ( 'class' => array ( 'links' , 'inline' )), ); } |
Please login to continue.