function ContentLanguageSettings::getAllValidDefaultLangcodes

Same name in other branches
  1. 10 core/modules/language/src/Entity/ContentLanguageSettings.php \Drupal\language\Entity\ContentLanguageSettings::getAllValidDefaultLangcodes()

Returns all valid values for the `default_langcode` property.

Return value

string[] All possible valid default langcodes. This includes all langcodes in the standard list of human languages, along with special langcodes like `site_default`, `current_interface` and `authors_default`.

See also

\Drupal\language\Element\LanguageConfiguration::getDefaultOptions()

\Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes()

1 string reference to 'ContentLanguageSettings::getAllValidDefaultLangcodes'
language.schema.yml in core/modules/language/config/schema/language.schema.yml
core/modules/language/config/schema/language.schema.yml

File

core/modules/language/src/Entity/ContentLanguageSettings.php, line 231

Class

ContentLanguageSettings
Defines the ContentLanguageSettings entity.

Namespace

Drupal\language\Entity

Code

public static function getAllValidDefaultLangcodes() : array {
    $language_manager = \Drupal::service('language_manager');
    return array_unique([
        array_keys($language_manager->getLanguages(LanguageInterface::STATE_ALL)),
        LanguageInterface::LANGCODE_SITE_DEFAULT,
        'current_interface',
        'authors_default',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.