You are here

function matomo_cron in Matomo Analytics 8

Same name and namespace in other branches
  1. 7.2 matomo.module \matomo_cron()

Implements hook_cron().

File

./matomo.module, line 443
Drupal Module: Matomo.

Code

function matomo_cron() {
  $config = \Drupal::config('matomo.settings');
  $request_time = \Drupal::time()
    ->getRequestTime();

  // Regenerate the matomo.js every day.
  if ($request_time - \Drupal::state()
    ->get('matomo.last_cache') >= 86400 && $config
    ->get('cache')) {
    _matomo_cache($config
      ->get('url_http') . 'matomo.js', TRUE);
    \Drupal::state()
      ->set('matomo.last_cache', $request_time);
  }
}