You are here

public function Ip2CountryCommands::status in IP-based Determination of a Visitor's Country 8

Displays the time and RIR of the last database update.

@command ip2country:status @aliases ip-status,ip2country-status

@usage drush ip2country:status Returns a country code associated with the given IP address.

@validate-module-enabled ip2country

File

src/Commands/Ip2CountryCommands.php, line 221

Class

Ip2CountryCommands
Drush 9+ commands for the IP2Country module.

Namespace

Drupal\ip2country\Commands

Code

public function status() {
  $update_time = $this->stateService
    ->get('ip2country_last_update');
  if (!empty($update_time)) {
    $message = dt('Database last updated on @date at @time from @registry server.', [
      '@date' => $this->dateFormatter
        ->format($update_time, 'ip2country_date'),
      '@time' => $this->dateFormatter
        ->format($update_time, 'ip2country_time'),
      '@registry' => mb_strtoupper($this->stateService
        ->get('ip2country_last_update_rir')),
    ]);
  }
  else {
    $message = dt('Database is empty.');
  }
  $this->output
    ->writeln($message);
}