You are here

class CurrencyCacheContext in Commerce Currency Resolver 8

Defines the CurrencyCacheContext service, for "per currency" caching.

Cache context ID: 'currency_resolver'.

Hierarchy

Expanded class hierarchy of CurrencyCacheContext

1 string reference to 'CurrencyCacheContext'
commerce_currency_resolver.services.yml in ./commerce_currency_resolver.services.yml
commerce_currency_resolver.services.yml
1 service uses CurrencyCacheContext
cache_context.currency_resolver in ./commerce_currency_resolver.services.yml
Drupal\commerce_currency_resolver\Cache\Context\CurrencyCacheContext

File

src/Cache/Context/CurrencyCacheContext.php, line 14

Namespace

Drupal\commerce_currency_resolver\Cache\Context
View 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

Namesort descending Modifiers Type Description Overrides
CurrencyCacheContext::$currentCurrency protected property The current store.
CurrencyCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
CurrencyCacheContext::getContext public function Returns the string representation of the cache context. Overrides CacheContextInterface::getContext
CurrencyCacheContext::getLabel public static function Returns the label of the cache context. Overrides CacheContextInterface::getLabel
CurrencyCacheContext::__construct public function Constructs a new StoreCacheContext class.