You are here

function statistics_node_view in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/statistics/statistics.module \statistics_node_view()

Implements hook_ENTITY_TYPE_view() for node entities.

File

core/modules/statistics/statistics.module, line 40
Logs and displays content statistics for a site.

Code

function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  if (!$node
    ->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
    $build['#attached']['library'][] = 'statistics/drupal.statistics';
    $settings = array(
      'data' => array(
        'nid' => $node
          ->id(),
      ),
      'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')
        ->toString(),
    );
    $build['#attached']['drupalSettings']['statistics'] = $settings;
  }
}