LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName

protected LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName($collection)

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()

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\Config

Code

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];
}
doc_Drupal
2016-10-29 09:22:04
Comments
Leave a Comment

Please login to continue.