You are here

public function SmartIpEventSubscriber::manualUpdate in Smart IP 8.3

Same name in this branch
  1. 8.3 modules/device_geolocation/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\device_geolocation\EventSubscriber\SmartIpEventSubscriber::manualUpdate()
  2. 8.3 modules/smart_ip_maxmind_geoip2_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_bin_db\EventSubscriber\SmartIpEventSubscriber::manualUpdate()
  3. 8.3 modules/smart_ip_ipinfodb_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ipinfodb_web_service\EventSubscriber\SmartIpEventSubscriber::manualUpdate()
  4. 8.3 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::manualUpdate()
  5. 8.3 modules/smart_ip_abstract_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_abstract_web_service\EventSubscriber\SmartIpEventSubscriber::manualUpdate()
  6. 8.3 modules/smart_ip_maxmind_geoip2_web_service/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_maxmind_geoip2_web_service\EventSubscriber\SmartIpEventSubscriber::manualUpdate()
Same name and namespace in other branches
  1. 8.4 modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php \Drupal\smart_ip_ip2location_bin_db\EventSubscriber\SmartIpEventSubscriber::manualUpdate()

Act on manual database update.

Parameters

\Drupal\smart_ip\DatabaseFileEvent $event: Smart IP database file related events for event listeners.

Overrides SmartIpDataSourceInterface::manualUpdate

File

modules/smart_ip_ip2location_bin_db/src/EventSubscriber/SmartIpEventSubscriber.php, line 492
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\EventSubscriber

Code

public function manualUpdate(DatabaseFileEvent $event) {
  $dataSource = \Drupal::config('smart_ip.settings')
    ->get('data_source');
  if ($dataSource == self::sourceId()) {
    $ipVersion = \Drupal::state()
      ->get('smart_ip_ip2location_bin_db.current_ip_version_queue');
    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);
  }
}