class CountryCacheContext in Price 3.x
Same name and namespace in other branches
- 8 src/Cache/Context/CountryCacheContext.php \Drupal\price\Cache\Context\CountryCacheContext
- 2.0.x src/Cache/Context/CountryCacheContext.php \Drupal\price\Cache\Context\CountryCacheContext
- 2.x src/Cache/Context/CountryCacheContext.php \Drupal\price\Cache\Context\CountryCacheContext
- 3.0.x src/Cache/Context/CountryCacheContext.php \Drupal\price\Cache\Context\CountryCacheContext
Defines the country cache context, for "per country" caching.
Cache context ID: 'country'.
Hierarchy
- class \Drupal\price\Cache\Context\CountryCacheContext implements CacheContextInterface
Expanded class hierarchy of CountryCacheContext
1 string reference to 'CountryCacheContext'
1 service uses CountryCacheContext
File
- src/Cache/ Context/ CountryCacheContext.php, line 14 
Namespace
Drupal\price\Cache\ContextView source
class CountryCacheContext implements CacheContextInterface {
  /**
   * The current country.
   *
   * @var \Drupal\price\CurrentCountry
   */
  protected $currentCountry;
  /**
   * Constructs a new CountryCacheContext object.
   *
   * @param \Drupal\price\CurrentCountry $country
   *   The current country.
   */
  public function __construct(CurrentCountry $country) {
    $this->currentCountry = $country;
  }
  /**
   * {@inheritdoc}
   */
  public static function getLabel() {
    return t('Country');
  }
  /**
   * {@inheritdoc}
   */
  public function getContext() {
    return $this->currentCountry
      ->getCountry()
      ->getCountryCode();
  }
  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata() {
    return new CacheableMetadata();
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| CountryCacheContext:: | protected | property | The current country. | |
| CountryCacheContext:: | public | function | Gets the cacheability metadata for the context. Overrides CacheContextInterface:: | |
| CountryCacheContext:: | public | function | Returns the string representation of the cache context. Overrides CacheContextInterface:: | |
| CountryCacheContext:: | public static | function | Returns the label of the cache context. Overrides CacheContextInterface:: | |
| CountryCacheContext:: | public | function | Constructs a new CountryCacheContext object. | 
