function DefaultLanguageItem::applyDefaultValue
Same name in other branches
- 8.9.x core/modules/language/src/DefaultLanguageItem.php \Drupal\language\DefaultLanguageItem::applyDefaultValue()
- 10 core/modules/language/src/DefaultLanguageItem.php \Drupal\language\DefaultLanguageItem::applyDefaultValue()
- 11.x core/modules/language/src/DefaultLanguageItem.php \Drupal\language\DefaultLanguageItem::applyDefaultValue()
Overrides LanguageItem::applyDefaultValue
File
-
core/
modules/ language/ src/ DefaultLanguageItem.php, line 25
Class
- DefaultLanguageItem
- Alternative plugin implementation of the 'language' field type.
Namespace
Drupal\languageCode
public function applyDefaultValue($notify = TRUE) {
// Default to LANGCODE_NOT_SPECIFIED.
$langcode = Language::LANGCODE_NOT_SPECIFIED;
if ($entity = $this->getEntity()) {
$langcode = $this->getDefaultLangcode($entity);
}
// Always notify otherwise default langcode will not be set correctly.
$this->setValue([
'value' => $langcode,
], TRUE);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.