You are here

public function CurrentCountry::getCountry in Price 8

Same name and namespace in other branches
  1. 3.x src/CurrentCountry.php \Drupal\price\CurrentCountry::getCountry()
  2. 2.0.x src/CurrentCountry.php \Drupal\price\CurrentCountry::getCountry()
  3. 2.x src/CurrentCountry.php \Drupal\price\CurrentCountry::getCountry()
  4. 3.0.x src/CurrentCountry.php \Drupal\price\CurrentCountry::getCountry()

Gets the country for the current request.

Return value

\Drupal\price\Country The country.

Overrides CurrentCountryInterface::getCountry

File

src/CurrentCountry.php, line 59

Class

CurrentCountry
Holds a reference to the current country, resolved on demand.

Namespace

Drupal\price

Code

public function getCountry() {
  $request = $this->requestStack
    ->getCurrentRequest();
  if (!$this->countries
    ->contains($request)) {
    $this->countries[$request] = $this->chainResolver
      ->resolve();
  }
  return $this->countries[$request];
}