You are here

public function UserCountry::summary in Smart IP 8.4

Same name and namespace in other branches
  1. 8.3 src/Plugin/Condition/UserCountry.php \Drupal\smart_ip\Plugin\Condition\UserCountry::summary()

Provides a human readable summary of the condition's configuration.

Overrides ConditionInterface::summary

File

src/Plugin/Condition/UserCountry.php, line 73
Contains \Drupal\smart_ip\Plugin\Condition\UserCountry.

Class

UserCountry
Provides 'Countries' condition.

Namespace

Drupal\smart_ip\Plugin\Condition

Code

public function summary() {
  $countryCodes = $this->configuration['countries'];
  module_load_include('inc', 'smart_ip', 'includes/smart_ip.country_list');
  $allCountries = country_get_predefined_list();
  foreach ($countryCodes as $countryCode) {
    $countries[] = $allCountries[$countryCode];
  }
  $countries = implode(', ', $countries);
  if (!empty($this->configuration['negate'])) {
    return $this
      ->t('Do not return true on the following countries: @countries', [
      '@countries' => $countries,
    ]);
  }
  return $this
    ->t('Return true on the following countries: @countries', [
    '@countries' => $countries,
  ]);
}