You are here

public function CurrentLocale::getLocale in Price 8

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

Gets the locale for the current request.

Return value

\Drupal\price\Locale The locale.

Overrides CurrentLocaleInterface::getLocale

File

src/CurrentLocale.php, line 59

Class

CurrentLocale
Holds a reference to the current locale, resolved on demand.

Namespace

Drupal\price

Code

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