class DatabaseFileUtility in Smart IP 8.4
Same name in this branch
- 8.4 modules/smart_ip_maxmind_geoip2_bin_db/src/DatabaseFileUtility.php \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility
- 8.4 modules/smart_ip_ip2location_bin_db/src/DatabaseFileUtility.php \Drupal\smart_ip_ip2location_bin_db\DatabaseFileUtility
Same name and namespace in other branches
- 8.3 modules/smart_ip_maxmind_geoip2_bin_db/src/DatabaseFileUtility.php \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility
Utility methods class wrapper.
@package Drupal\smart_ip_maxmind_geoip2_bin_db
Hierarchy
- class \Drupal\smart_ip\DatabaseFileUtilityBase implements DatabaseFileUtilityInterface
- class \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility
Expanded class hierarchy of DatabaseFileUtility
1 file declares its use of DatabaseFileUtility
- SmartIpEventSubscriber.php in modules/
smart_ip_maxmind_geoip2_bin_db/ src/ EventSubscriber/ SmartIpEventSubscriber.php - Contains \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber.
File
- modules/
smart_ip_maxmind_geoip2_bin_db/ src/ DatabaseFileUtility.php, line 20 - Contains \Drupal\smart_ip_maxmind_geoip2_bin_db\DatabaseFileUtility.
Namespace
Drupal\smart_ip_maxmind_geoip2_bin_dbView source
class DatabaseFileUtility extends DatabaseFileUtilityBase {
/**
* Get MaxMind GeoIP2 binary database filename.
*
* @param string $version
* @param string $edition
* @param bool $withExt
* @return string
*/
public static function getFilename($version = MaxmindGeoip2BinDb::LITE_VERSION, $edition = MaxmindGeoip2BinDb::CITY_EDITION, $withExt = TRUE) {
if ($version == MaxmindGeoip2BinDb::LINCENSED_VERSION && $edition == MaxmindGeoip2BinDb::COUNTRY_EDITION) {
$file = MaxmindGeoip2BinDb::FILENAME_LINCENSED_COUNTRY;
}
elseif ($version == MaxmindGeoip2BinDb::LINCENSED_VERSION && $edition == MaxmindGeoip2BinDb::CITY_EDITION) {
$file = MaxmindGeoip2BinDb::FILENAME_LINCENSED_CITY;
}
elseif ($version == MaxmindGeoip2BinDb::LITE_VERSION && $edition == MaxmindGeoip2BinDb::COUNTRY_EDITION) {
$file = MaxmindGeoip2BinDb::FILENAME_LITE_COUNTRY;
}
else {
$file = MaxmindGeoip2BinDb::FILENAME_LITE_CITY;
}
if ($withExt) {
return $file . MaxmindGeoip2BinDb::FILE_EXTENSION;
}
return $file;
}
/**
* Download MaxMind GeoIP2 binary database file and extract it.
* Only perform this action when the database is out of date or under specific
* direction.
*/
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());
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DatabaseFileUtility:: |
public static | function | Download MaxMind GeoIP2 binary database file and extract it. Only perform this action when the database is out of date or under specific direction. | |
DatabaseFileUtility:: |
public static | function |
Get MaxMind GeoIP2 binary database filename. Overrides DatabaseFileUtilityInterface:: |
|
DatabaseFileUtilityBase:: |
constant | Download Smart IP's data source module's database file monthly. | ||
DatabaseFileUtilityBase:: |
constant | Download Smart IP's data source module's database timout. | ||
DatabaseFileUtilityBase:: |
constant | Download Smart IP's data source module's database file weekly. | ||
DatabaseFileUtilityBase:: |
constant | Fixed Drupal folder path of Smart IP data source module's database file is stored. | ||
DatabaseFileUtilityBase:: |
constant | Drupal temporary folder path. | ||
DatabaseFileUtilityBase:: |
public static | function |
Get Smart IP's data source module's database file's path. This should
return the fixed Drupal folder if auto update is on or if custom path is
empty with auto update off. Overrides DatabaseFileUtilityInterface:: |
|
DatabaseFileUtilityBase:: |
public static | function |
Checks if Smart IP's data source module's database file needs update. Overrides DatabaseFileUtilityInterface:: |
|
DatabaseFileUtilityBase:: |
protected static | function | Download Smart IP's data source module's database file and extract it. |