You are here

class DefaultCountryResolver in Commerce Core 8.2

Returns the site's default country.

Hierarchy

Expanded class hierarchy of DefaultCountryResolver

1 file declares its use of DefaultCountryResolver
DefaultCountryResolverTest.php in tests/src/Unit/Resolver/DefaultCountryResolverTest.php
1 string reference to 'DefaultCountryResolver'
commerce.services.yml in ./commerce.services.yml
commerce.services.yml
1 service uses DefaultCountryResolver
commerce.default_country_resolver in ./commerce.services.yml
Drupal\commerce\Resolver\DefaultCountryResolver

File

src/Resolver/DefaultCountryResolver.php, line 11

Namespace

Drupal\commerce\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.