You are here

class DefaultCountryResolver in Price 2.0.x

Same name and namespace in other branches
  1. 8 src/Resolver/DefaultCountryResolver.php \Drupal\price\Resolver\DefaultCountryResolver
  2. 3.x src/Resolver/DefaultCountryResolver.php \Drupal\price\Resolver\DefaultCountryResolver
  3. 2.x src/Resolver/DefaultCountryResolver.php \Drupal\price\Resolver\DefaultCountryResolver
  4. 3.0.x src/Resolver/DefaultCountryResolver.php \Drupal\price\Resolver\DefaultCountryResolver

Returns the site's default country.

Hierarchy

Expanded class hierarchy of DefaultCountryResolver

1 string reference to 'DefaultCountryResolver'
price.services.yml in ./price.services.yml
price.services.yml
1 service uses DefaultCountryResolver
price.default_country_resolver in ./price.services.yml
Drupal\price\Resolver\DefaultCountryResolver

File

src/Resolver/DefaultCountryResolver.php, line 11

Namespace

Drupal\price\Resolver
View source
class DefaultCountryResolver implements CountryResolverInterface {

  /**
   * The configuration factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Constructs a new DefaultCountryResolver object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   */
  public function __construct(ConfigFactoryInterface $config_factory) {
    $this->configFactory = $config_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function resolve() {
    $country_code = $this->configFactory
      ->get('system.date')
      ->get('country.default');
    return new Country($country_code);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultCountryResolver::$configFactory protected property The configuration factory.
DefaultCountryResolver::resolve public function Resolves the country. Overrides CountryResolverInterface::resolve
DefaultCountryResolver::__construct public function Constructs a new DefaultCountryResolver object.