public function SmartIpEventSubscriber::cronRun in Smart IP 8.3
Same name in this branch
- 8.3 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.3 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.3 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.3 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.3 modules/smart_ip_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.3 modules/smart_ip_maxmind_geoip2_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_web_service\EventSubscriber\SmartIpEventSubscriber::cronRun()
Same name and namespace in other branches
- 8.4 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::cronRun()
MaxMind GeoIP2 updates the binary database every Tuesday (both lite and licensed versions), and we download every Wednesday. That means that we only want to download if the current database was downloaded prior to the most recently available version.
Overrides SmartIpDataSourceInterface::cronRun
File
- modules/
smart_ip_maxmind_geoip2_bin_db/ src/ EventSubscriber/ SmartIpEventSubscriber.php, line 389 - Contains \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber.
Class
- SmartIpEventSubscriber
- Core functionality of this Smart IP data source module. Listens to Smart IP override events.
Namespace
Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriberCode
public function cronRun(DatabaseFileEvent $event) {
$dataSource = \Drupal::config('smart_ip.settings')
->get('data_source');
if ($dataSource == self::sourceId()) {
$config = \Drupal::config(self::configName());
$autoUpdate = $config
->get('db_auto_update');
$version = $config
->get('version');
$lastUpdateTime = \Drupal::state()
->get('smart_ip_maxmind_geoip2_bin_db.last_update_time') ?: 0;
$frequency = DatabaseFileUtility::DOWNLOAD_WEEKLY;
if (DatabaseFileUtility::needsUpdate($lastUpdateTime, $autoUpdate, $frequency)) {
DatabaseFileUtility::downloadDatabaseFile();
}
}
}