class CurrencyCacheContext in Commerce Currency Resolver 8
Defines the CurrencyCacheContext service, for "per currency" caching.
Cache context ID: 'currency_resolver'.
Hierarchy
- class \Drupal\commerce_currency_resolver\Cache\Context\CurrencyCacheContext implements CacheContextInterface
Expanded class hierarchy of CurrencyCacheContext
1 string reference to 'CurrencyCacheContext'
1 service uses CurrencyCacheContext
File
- src/
Cache/ Context/ CurrencyCacheContext.php, line 14
Namespace
Drupal\commerce_currency_resolver\Cache\ContextView source
class CurrencyCacheContext implements CacheContextInterface {
/**
* The current store.
*
* @var \Drupal\commerce_currency_resolver\CurrentCurrency
*/
protected $currentCurrency;
/**
* Constructs a new StoreCacheContext class.
*
* @param \Drupal\commerce_currency_resolver\CurrentCurrency $current_currency
* The current currency.
*/
public function __construct(CurrentCurrency $current_currency) {
$this->currentCurrency = $current_currency;
}
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('Currency');
}
/**
* {@inheritdoc}
*/
public function getContext() {
return $this->currentCurrency
->getCurrency();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CurrencyCacheContext:: |
protected | property | The current store. | |
CurrencyCacheContext:: |
public | function |
Gets the cacheability metadata for the context. Overrides CacheContextInterface:: |
|
CurrencyCacheContext:: |
public | function |
Returns the string representation of the cache context. Overrides CacheContextInterface:: |
|
CurrencyCacheContext:: |
public static | function |
Returns the label of the cache context. Overrides CacheContextInterface:: |
|
CurrencyCacheContext:: |
public | function | Constructs a new StoreCacheContext class. |