You are here

protected function LanguageConfigCollectionNameTrait::getLangcodeFromCollectionName in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 43
Contains \Drupal\language\Config\LanguageConfigCollectionNameTrait.

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];
}