You are here

public function Ip2CountryCacheContext::getContext in IP-based Determination of a Visitor's Country 8

Returns the string representation of the cache context.

A cache context service's name is used as a token (placeholder) cache key, and is then replaced with the string returned by this method.

Return value

string The string representation of the cache context.

Overrides CacheContextInterface::getContext

File

src/Cache/Context/Ip2CountryCacheContext.php, line 48

Class

Ip2CountryCacheContext
Defines the Ip2CountryCacheContext service, for "per country" caching.

Namespace

Drupal\ip2country\Cache\Context

Code

public function getContext() {
  return $this->ip2countryLookup
    ->getCountry($this->requestStack
    ->getCurrentRequest()
    ->getClientIp());
}