function LocaleDefaultConfigStorage::read

Same name in other branches
  1. 9 core/modules/locale/src/LocaleDefaultConfigStorage.php \Drupal\locale\LocaleDefaultConfigStorage::read()
  2. 8.9.x core/modules/locale/src/LocaleDefaultConfigStorage.php \Drupal\locale\LocaleDefaultConfigStorage::read()
  3. 10 core/modules/locale/src/LocaleDefaultConfigStorage.php \Drupal\locale\LocaleDefaultConfigStorage::read()

Read a configuration from install storage or default languages.

Parameters

string $name: Configuration object name.

Return value

array Configuration data from install storage or default language.

File

core/modules/locale/src/LocaleDefaultConfigStorage.php, line 79

Class

LocaleDefaultConfigStorage
Provides access to default configuration for locale integration.

Namespace

Drupal\locale

Code

public function read($name) {
    if ($this->requiredInstallStorage
        ->exists($name)) {
        return $this->requiredInstallStorage
            ->read($name);
    }
    elseif ($this->optionalInstallStorage
        ->exists($name)) {
        return $this->optionalInstallStorage
            ->read($name);
    }
    elseif (str_starts_with($name, 'language.entity.')) {
        // Simulate default languages as if they were shipped as default
        // configuration.
        $langcode = str_replace('language.entity.', '', $name);
        $predefined_languages = $this->languageManager
            ->getStandardLanguageList();
        if (isset($predefined_languages[$langcode])) {
            $data = $this->configStorage
                ->read($name);
            $data['label'] = $predefined_languages[$langcode][0];
            return $data;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.