protected function LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName in Drupal 9
Same name and namespace in other branches
- 8 core/modules/language/src/Config/LanguageConfigCollectionNameTrait.php \Drupal\language\Config\LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName()
Converts a configuration collection name to a language code.
Parameters
string $collection: The configuration collection name.
Return value
string The language code of the collection.
Throws
\InvalidArgumentException Exception thrown if the provided collection name is not in the format "language.LANGCODE".
See also
self::createConfigCollectionName()
2 calls to LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName()
- LanguageConfigFactoryOverride::createConfigObject in core/
modules/ language/ src/ Config/ LanguageConfigFactoryOverride.php - Creates a configuration object for use during install and synchronization.
- LanguageConfigOverride::getLangcode in core/
modules/ language/ src/ Config/ LanguageConfigOverride.php - Returns the language code of this language override.
File
- core/
modules/ language/ src/ Config/ LanguageConfigCollectionNameTrait.php, line 38
Class
- LanguageConfigCollectionNameTrait
- Provides a common trait for working with language override collection names.
Namespace
Drupal\language\ConfigCode
protected function getLangcodeFromCollectionName($collection) {
preg_match('/^language\\.(.*)$/', $collection, $matches);
if (!isset($matches[1])) {
throw new \InvalidArgumentException("'{$collection}' is not a valid language override collection");
}
return $matches[1];
}