function DefaultLanguageItem::getDefaultLangcode

Same name in other branches
  1. 9 core/modules/language/src/DefaultLanguageItem.php \Drupal\language\DefaultLanguageItem::getDefaultLangcode()
  2. 8.9.x core/modules/language/src/DefaultLanguageItem.php \Drupal\language\DefaultLanguageItem::getDefaultLangcode()
  3. 11.x core/modules/language/src/DefaultLanguageItem.php \Drupal\language\DefaultLanguageItem::getDefaultLangcode()

Provides default language code of given entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity whose language code to be loaded.

Return value

string A string language code.

1 call to DefaultLanguageItem::getDefaultLangcode()
DefaultLanguageItem::applyDefaultValue in core/modules/language/src/DefaultLanguageItem.php
Applies the default value.

File

core/modules/language/src/DefaultLanguageItem.php, line 45

Class

DefaultLanguageItem
Alternative plugin implementation of the 'language' field type.

Namespace

Drupal\language

Code

public function getDefaultLangcode(EntityInterface $entity) {
    return language_get_default_langcode($entity->getEntityTypeId(), $entity->bundle());
}

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