statistics_node_links_alter(array &$links, NodeInterface $entity, array &$context)
Implements hook_node_links_alter().
File
- core/modules/statistics/statistics.module, line 51
- Logs and displays content statistics for a site.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function statistics_node_links_alter( array & $links , NodeInterface $entity , array & $context ) { if ( $context [ 'view_mode' ] != 'rss' ) { $links [ '#cache' ][ 'contexts' ][] = 'user.permissions' ; if (\Drupal::currentUser()->hasPermission( 'view post access counter' )) { $statistics = statistics_get( $entity ->id()); if ( $statistics ) { $statistics_links [ 'statistics_counter' ][ 'title' ] = \Drupal::translation()->formatPlural( $statistics [ 'totalcount' ], '1 view' , '@count views' ); $links [ 'statistics' ] = array ( '#theme' => 'links__node__statistics' , '#links' => $statistics_links , '#attributes' => array ( 'class' => array ( 'links' , 'inline' )), ); } $links [ '#cache' ][ 'max-age' ] = \Drupal::config( 'statistics.settings' )->get( 'display_max_age' ); } } } |
Please login to continue.