function NodeStatisticsDatabaseStorage::fetchView

Same name and namespace in other branches
  1. 9 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::fetchView()
  2. 8.9.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::fetchView()
  3. 11.x core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::fetchView()

Returns the number of times a single entity has been viewed.

Parameters

int $id: The ID of the entity to fetch the views for.

Return value

\Drupal\statistics\StatisticsViewsResult|false If the entity exists, a value object representing the number of times if has been viewed. If it does not exist, FALSE is returned.

Overrides StatisticsStorageInterface::fetchView

File

core/modules/statistics/src/NodeStatisticsDatabaseStorage.php, line 89

Class

NodeStatisticsDatabaseStorage
Provides the default database storage backend for statistics.

Namespace

Drupal\statistics

Code

public function fetchView($id) {
  $views = $this->fetchViews([
    $id,
  ]);
  return reset($views);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.