ConfigNamesMapper::getLangcode

public ConfigNamesMapper::getLangcode()

Returns the original language code of the configuration.

Throws

\RuntimeException Throws an exception if the language codes in the config files don't match.

Overrides ConfigMapperInterface::getLangcode

File

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

Class

ConfigNamesMapper
Configuration mapper base implementation.

Namespace

Drupal\config_translation

Code

1
2
3
4
5
6
7
8
9
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);
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.