class DefaultCountryResolver in Commerce Core 8.2
Returns the site's default country.
Hierarchy
- class \Drupal\commerce\Resolver\DefaultCountryResolver implements CountryResolverInterface
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'
1 service uses DefaultCountryResolver
File
- src/
Resolver/ DefaultCountryResolver.php, line 11
Namespace
Drupal\commerce\ResolverView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultCountryResolver:: |
protected | property | The configuration factory. | |
DefaultCountryResolver:: |
public | function |
Resolves the country. Overrides CountryResolverInterface:: |
|
DefaultCountryResolver:: |
public | function | Constructs a new DefaultCountryResolver object. |