You are here

function file_download_counter_increment_file in File Download 8

Public function to increment file counter against fid

Parameters

$fid:

1 call to file_download_counter_increment_file()
FileDownloadDownloadController::deliver in src/Controller/FileDownloadDownloadController.php
Generates a download.

File

modules/file_download_counter/file_download_counter.module, line 168
Logs and displays content file_download_counter for a site.

Code

function file_download_counter_increment_file($fid) {
  \Drupal::database()
    ->merge('file_download_counter')
    ->key('fid', $fid)
    ->fields([
    'daycount' => 1,
    'totalcount' => 1,
    'timestamp' => \Drupal::time()
      ->getRequestTime(),
  ])
    ->expression('daycount', 'daycount + 1')
    ->expression('totalcount', 'totalcount + 1')
    ->execute();
}