You are here

DefaultCountryResolver.php in Price 2.x

File

src/Resolver/DefaultCountryResolver.php
View source
<?php

namespace Drupal\price\Resolver;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\price\Country;

/**
 * Returns the site's default country.
 */
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);
  }

}

Classes

Namesort descending Description
DefaultCountryResolver Returns the site's default country.