function ConfigNamesMapper::getLangcode

Same name in other branches
  1. 8.9.x core/modules/config_translation/src/ConfigNamesMapper.php \Drupal\config_translation\ConfigNamesMapper::getLangcode()
  2. 10 core/modules/config_translation/src/ConfigNamesMapper.php \Drupal\config_translation\ConfigNamesMapper::getLangcode()
  3. 11.x core/modules/config_translation/src/ConfigNamesMapper.php \Drupal\config_translation\ConfigNamesMapper::getLangcode()

Overrides ConfigMapperInterface::getLangcode

File

core/modules/config_translation/src/ConfigNamesMapper.php, line 400

Class

ConfigNamesMapper
Configuration mapper base implementation.

Namespace

Drupal\config_translation

Code

public function getLangcode() {
    $langcodes = array_map([
        $this,
        'getLangcodeFromConfig',
    ], $this->getConfigNames());
    if (count(array_unique($langcodes)) > 1) {
        throw new ConfigMapperLanguageException('A config mapper can only contain configuration for a single language.');
    }
    return reset($langcodes);
}

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