function browscap_cron in Browscap 8.3
Same name and namespace in other branches
- 8 browscap.module \browscap_cron()
- 5 browscap.module \browscap_cron()
- 6.2 browscap.module \browscap_cron()
- 6 browscap.module \browscap_cron()
- 7.2 browscap.module \browscap_cron()
- 7 browscap.module \browscap_cron()
Implements hook_cron().
File
- ./
browscap.module, line 26 - Replacement for PHP's get_browser() function.
Code
function browscap_cron() {
$config = \Drupal::configFactory()
->getEditable('browscap.settings');
if ($config
->get('enable_automatic_updates') == TRUE) {
// Check the current update timer.
$automatic_update_timer = $config
->get('automatic_updates_timer');
// Check when the last update occurred.
$last_imported = $config
->get('imported');
// Update the browscap data if the amount of time specified by the update
// timer has passed.
if ($last_imported + $automatic_update_timer < REQUEST_TIME) {
// Update the browscap information.
$endpoint = new BrowscapEndpoint();
\Drupal::service('browscap.importer')
->import($endpoint);
// Record when the browscap information was updated.
$config
->set('imported', REQUEST_TIME);
}
}
}