Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LanguageConfigCollectionNameTrait.php

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal