public static function DatabaseFileUtility::downloadDatabaseFile in Smart IP 8.3
Same name in this branch
- 8.3 modules/smart_ip_maxmind_geoip2_bin_db/src/DatabaseFileUtility.php \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility::downloadDatabaseFile()
- 8.3 modules/smart_ip_ip2location_bin_db/src/DatabaseFileUtility.php \Drupal\smart_ip_ip2location_bin_db\DatabaseFileUtility::downloadDatabaseFile()
Same name and namespace in other branches
- 8.4 modules/smart_ip_maxmind_geoip2_bin_db/src/DatabaseFileUtility.php \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility::downloadDatabaseFile()
Download MaxMind GeoIP2 binary database file and extract it. Only perform this action when the database is out of date or under specific direction.
2 calls to DatabaseFileUtility::downloadDatabaseFile()
- SmartIpEventSubscriber::cronRun in modules/
smart_ip_maxmind_geoip2_bin_db/ src/ EventSubscriber/ SmartIpEventSubscriber.php - 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.
- SmartIpEventSubscriber::manualUpdate in modules/
smart_ip_maxmind_geoip2_bin_db/ src/ EventSubscriber/ SmartIpEventSubscriber.php - Act on manual database update.
File
- modules/
smart_ip_maxmind_geoip2_bin_db/ src/ DatabaseFileUtility.php, line 54 - Contains \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility.
Class
- DatabaseFileUtility
- Utility methods class wrapper.
Namespace
Drupal\smart_ip_maxmind_geoip2_bin_dbCode
public static function downloadDatabaseFile() {
$config = \Drupal::config(SmartIpEventSubscriber::configName());
$version = $config
->get('version');
$edition = $config
->get('edition');
$sourceId = SmartIpEventSubscriber::sourceId();
$file = self::getFilename($version, $edition);
$url = '';
if ($version == MaxmindGeoip2BinDb::LINCENSED_VERSION) {
$url = MaxmindGeoip2BinDb::LINCENSED_DL_URL;
$url .= '?' . UrlHelper::buildQuery([
'license_key' => $config
->get('license_key'),
'edition_id' => self::getFilename($version, $edition, FALSE),
'suffix' => 'tar.gz',
]);
}
elseif ($version == MaxmindGeoip2BinDb::LITE_VERSION) {
$url = MaxmindGeoip2BinDb::LITE_DL_URL;
$url .= '?' . UrlHelper::buildQuery([
'account_id' => $config
->get('user_account'),
'license_key' => $config
->get('license_key'),
'edition_id' => self::getFilename($version, $edition, FALSE),
'suffix' => 'tar.gz',
]);
}
if (parent::requestDatabaseFile($url, $file, $sourceId)) {
\Drupal::state()
->set('smart_ip_maxmind_geoip2_bin_db.last_update_time', \Drupal::time()
->getRequestTime());
}
}