You are here

protected function CountryRepository::loadDefinitions in Address 8

File

src/Repository/CountryRepository.php, line 43

Class

CountryRepository
Defines the country repository.

Namespace

Drupal\address\Repository

Code

protected function loadDefinitions($locale) {
  if (isset($this->definitions[$locale])) {
    return $this->definitions[$locale];
  }
  $cache_key = 'address.countries.' . $locale;
  if ($cached = $this->cache
    ->get($cache_key)) {
    $this->definitions[$locale] = $cached->data;
  }
  else {
    $filename = $this->definitionPath . $locale . '.json';
    $this->definitions[$locale] = json_decode(file_get_contents($filename), TRUE);
    $this->cache
      ->set($cache_key, $this->definitions[$locale], CacheBackendInterface::CACHE_PERMANENT, [
      'countries',
    ]);
  }
  return $this->definitions[$locale];
}