public function NodeStatisticsDatabaseStorage::resetDayCount in Drupal 9
Same name and namespace in other branches
- 8 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()
- 10 core/modules/statistics/src/NodeStatisticsDatabaseStorage.php \Drupal\statistics\NodeStatisticsDatabaseStorage::resetDayCount()
Reset the day counter for all entities once every day.
Overrides StatisticsStorageInterface::resetDayCount
File
- core/
modules/ statistics/ src/ NodeStatisticsDatabaseStorage.php, line 120
Class
- NodeStatisticsDatabaseStorage
- Provides the default database storage backend for statistics.
Namespace
Drupal\statisticsCode
public function resetDayCount() {
$statistics_timestamp = $this->state
->get('statistics.day_timestamp', 0);
if ($this
->getRequestTime() - $statistics_timestamp >= 86400) {
$this->state
->set('statistics.day_timestamp', $this
->getRequestTime());
$this->connection
->update('node_counter')
->fields([
'daycount' => 0,
])
->execute();
}
}