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
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.