public function SmartIpEventSubscriber::cronRun in Smart IP 8.4
Same name in this branch
- 8.4 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.4 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.4 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.4 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.4 modules/smart_ip_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber::cronRun()
- 8.4 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.3 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::cronRun()
Act on Drupal cron run.
Parameters
\Drupal\smart_ip\DatabaseFileEvent $event: Smart IP database file related events for event listeners.
Overrides SmartIpDataSourceInterface::cronRun
File
- modules/
smart_ip_ip2location_bin_db/ src/ EventSubscriber/ SmartIpEventSubscriber.php, line 509 - Contains \Drupal\smart_ip_ip2location_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_ip2location_bin_db\EventSubscriberCode
public function cronRun(DatabaseFileEvent $event) {
$dataSource = \Drupal::config('smart_ip.settings')
->get('data_source');
if ($dataSource == self::sourceId()) {
$config = \Drupal::config(SmartIpEventSubscriber::configName());
$autoUpdate = $config
->get('db_auto_update');
$ipVersion = \Drupal::state()
->get('smart_ip_ip2location_bin_db.current_ip_version_queue');
$lastUpdateTime = \Drupal::state()
->get('smart_ip_ip2location_bin_db.last_update_time') ?: 0;
if ($ipVersion || DatabaseFileUtility::needsUpdate($lastUpdateTime, $autoUpdate, DatabaseFileUtility::DOWNLOAD_MONTHLY)) {
if (empty($ipVersion)) {
// Update IPv4 IP2Location binary database first
$ipVersion = Ip2locationBinDb::IPV4_VERSION;
\Drupal::state()
->set('smart_ip_ip2location_bin_db.current_ip_version_queue', $ipVersion);
}
DatabaseFileUtility::downloadDatabaseFile($ipVersion);
}
}
}