Commit dd9c8373 authored by steveoliver's avatar steveoliver Committed by bojanz

Issue #2825066: Rename CountryContext and LocaleContext to CurrentCountry and CurrentLocale (#546)

parent 263d5ff1
......@@ -7,8 +7,8 @@ services:
class: Drupal\commerce\CredentialsCheckFlood
arguments: ['@flood', '@entity_type.manager', '@config.factory']
commerce.country_context:
class: Drupal\commerce\CountryContext
commerce.current_country:
class: Drupal\commerce\CurrentCountry
arguments: ['@request_stack', '@commerce.chain_country_resolver']
commerce.chain_country_resolver:
......@@ -22,8 +22,8 @@ services:
tags:
- { name: commerce.country_resolver, priority: -100 }
commerce.locale_context:
class: Drupal\commerce\LocaleContext
commerce.current_locale:
class: Drupal\commerce\CurrentLocale
arguments: ['@request_stack', '@commerce.chain_locale_resolver']
commerce.chain_locale_resolver:
......@@ -33,7 +33,7 @@ services:
commerce.default_locale_resolver:
class: Drupal\commerce\Resolver\DefaultLocaleResolver
arguments: ['@language_manager', '@commerce.country_context']
arguments: ['@language_manager', '@commerce.current_country']
tags:
- { name: commerce.locale_resolver, priority: -100 }
......@@ -52,6 +52,6 @@ services:
cache_context.country:
class: Drupal\commerce\Cache\Context\CountryCacheContext
arguments: ['@commerce.country_context']
arguments: ['@commerce.current_country']
tags:
- { name: cache.context}
......@@ -9,7 +9,7 @@ services:
commerce_price.number_formatter_factory:
class: Drupal\commerce_price\NumberFormatterFactory
arguments: ['@commerce.locale_context', '@commerce_price.number_format_repository']
arguments: ['@commerce.current_locale', '@commerce_price.number_format_repository']
commerce_price.chain_price_resolver:
class: Drupal\commerce_price\Resolver\ChainPriceResolver
......
......@@ -2,7 +2,7 @@
namespace Drupal\commerce_price;
use Drupal\commerce\LocaleContextInterface;
use Drupal\commerce\CurrentLocaleInterface;
use CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface;
use CommerceGuys\Intl\Formatter\NumberFormatter;
......@@ -12,11 +12,11 @@ use CommerceGuys\Intl\Formatter\NumberFormatter;
class NumberFormatterFactory implements NumberFormatterFactoryInterface {
/**
* The locale context.
* The current locale.
*
* @var \Drupal\commerce\LocaleContextInterface
* @var \Drupal\commerce\CurrentLocaleInterface
*/
protected $localeContext;
protected $currentLocale;
/**
* The number format repository.
......@@ -28,13 +28,13 @@ class NumberFormatterFactory implements NumberFormatterFactoryInterface {
/**
* Constructs a new NumberFormatterFactory object.
*
* @param \Drupal\commerce\LocaleContextInterface $locale_context
* The locale context.
* @param \Drupal\commerce\CurrentLocaleInterface $current_locale
* The current locale.
* @param \CommerceGuys\Intl\NumberFormat\NumberFormatRepositoryInterface $number_format_repository
* The number format repository..
*/
public function __construct(LocaleContextInterface $locale_context, NumberFormatRepositoryInterface $number_format_repository) {
$this->localeContext = $locale_context;
public function __construct(CurrentLocaleInterface $current_locale, NumberFormatRepositoryInterface $number_format_repository) {
$this->currentLocale = $current_locale;
$this->numberFormatRepository = $number_format_repository;
}
......@@ -42,7 +42,7 @@ class NumberFormatterFactory implements NumberFormatterFactoryInterface {
* {@inheritdoc}
*/
public function createInstance($style = NumberFormatter::CURRENCY) {
$locale = $this->localeContext->getLocale();
$locale = $this->currentLocale->getLocale();
$number_format = $this->numberFormatRepository->get($locale);
return new NumberFormatter($number_format, $style);
......
......@@ -2,7 +2,7 @@
namespace Drupal\commerce\Cache\Context;
use Drupal\commerce\CountryContext;
use Drupal\commerce\CurrentCountry;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\Context\CacheContextInterface;
......@@ -14,20 +14,20 @@ use Drupal\Core\Cache\Context\CacheContextInterface;
class CountryCacheContext implements CacheContextInterface {
/**
* The country context.
* The current country.
*
* @var \Drupal\commerce\CountryContext
* @var \Drupal\commerce\CurrentCountry
*/
protected $countryContext;
protected $currentCcountry;
/**
* Constructs a new CountryCacheContext object.
*
* @param \Drupal\commerce\CountryContext $context
* The country context.
* @param \Drupal\commerce\CurrentCountry $country
* The current country.
*/
public function __construct(CountryContext $context) {
$this->countryContext = $context;
public function __construct(CurrentCountry $country) {
$this->currentCountry = $country;
}
/**
......@@ -41,7 +41,7 @@ class CountryCacheContext implements CacheContextInterface {
* {@inheritdoc}
*/
public function getContext() {
return $this->countryContext->getCountry()->getCountryCode();
return $this->currentCountry->getCountry()->getCountryCode();
}
/**
......
......@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
* @see \Drupal\commerce\Resolver\ChainCountryResolver
* @see \Drupal\commerce\Resolver\DefaultCountryResolver
*/
class CountryContext implements CountryContextInterface {
class CurrentCountry implements CurrentCountryInterface {
/**
* The request stack.
......@@ -40,7 +40,7 @@ class CountryContext implements CountryContextInterface {
protected $countries;
/**
* Constructs a new CountryContext object.
* Constructs a new CurrentCountry object.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
......
......@@ -5,9 +5,9 @@ namespace Drupal\commerce;
/**
* Holds a reference to the current country, resolved on demand.
*
* @see \Drupal\commerce\CountryContext
* @see \Drupal\commerce\CurrentCountry
*/
interface CountryContextInterface {
interface CurrentCountryInterface {
/**
* Gets the country for the current request.
......
......@@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
* @see \Drupal\commerce\Resolver\ChainLocaleResolver
* @see \Drupal\commerce\Resolver\DefaultLocaleResolver
*/
class LocaleContext implements LocaleContextInterface {
class CurrentLocale implements CurrentLocaleInterface {
/**
* The request stack.
......@@ -40,7 +40,7 @@ class LocaleContext implements LocaleContextInterface {
protected $locales;
/**
* Constructs a new LocaleContext object.
* Constructs a new CurrentLocale object.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
......
......@@ -5,9 +5,9 @@ namespace Drupal\commerce;
/**
* Holds a reference to the current locale, resolved on demand.
*
* @see \Drupal\commerce\LocaleContext
* @see \Drupal\commerce\CurrentLocale
*/
interface LocaleContextInterface {
interface CurrentLocaleInterface {
/**
* Gets the locale for the current request.
......
......@@ -2,7 +2,7 @@
namespace Drupal\commerce\Resolver;
use Drupal\commerce\CountryContextInterface;
use Drupal\commerce\CurrentCountryInterface;
use Drupal\commerce\Locale;
use Drupal\Core\Language\LanguageManagerInterface;
......@@ -19,23 +19,23 @@ class DefaultLocaleResolver implements LocaleResolverInterface {
protected $languageManager;
/**
* The country context.
* The current country.
*
* @var \Drupal\commerce\CountryContextInterface
* @var \Drupal\commerce\CurrentCountryInterface
*/
protected $countryContext;
protected $currentCountry;
/**
* Constructs a new DefaultLocaleResolver object.
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\commerce\CountryContextInterface $country_context
* The country context.
* @param \Drupal\commerce\CurrentCountryInterface $current_country
* The current country.
*/
public function __construct(LanguageManagerInterface $language_manager, CountryContextInterface $country_context) {
public function __construct(LanguageManagerInterface $language_manager, CurrentCountryInterface $current_country) {
$this->languageManager = $language_manager;
$this->countryContext = $country_context;
$this->currentCountry = $current_country;
}
/**
......@@ -51,7 +51,7 @@ class DefaultLocaleResolver implements LocaleResolverInterface {
// it qualifies as a full locale.
$locale = $langcode;
}
elseif ($country = $this->countryContext->getCountry()) {
elseif ($country = $this->currentCountry->getCountry()) {
// Assemble the locale using the resolved country. This can result
// in non-existent combinations such as 'en-RS', it's up to the locale
// consumers (e.g. the number format repository) to perform fallback.
......
......@@ -29,7 +29,7 @@ class DefaultLocaleResolverTest extends UnitTestCase {
->method('getConfigOverrideLanguage')
->will($this->returnValue($language));
$country_context = $this->getMockBuilder('\Drupal\commerce\CountryContext')
$country_context = $this->getMockBuilder('\Drupal\commerce\CurrentCountry')
->disableOriginalConstructor()
->getMock();
$country_context->expects($this->once())
......@@ -58,7 +58,7 @@ class DefaultLocaleResolverTest extends UnitTestCase {
->method('getConfigOverrideLanguage')
->will($this->returnValue($language));
$country_context = $this->getMockBuilder('\Drupal\commerce\CountryContext')
$country_context = $this->getMockBuilder('\Drupal\commerce\CurrentCountry')
->disableOriginalConstructor()
->getMock();
......@@ -84,7 +84,7 @@ class DefaultLocaleResolverTest extends UnitTestCase {
->method('getConfigOverrideLanguage')
->will($this->returnValue($language));
$country_context = $this->getMockBuilder('\Drupal\commerce\CountryContext')
$country_context = $this->getMockBuilder('\Drupal\commerce\CurrentCountry')
->disableOriginalConstructor()
->getMock();
$country_context->expects($this->once())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment