function statistics_node_links_alter

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');
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!statistics!statistics.module/function/statistics_node_links_alter/8.1.x