public DefaultLanguageItem::applyDefaultValue($notify = TRUE)
Applies the default value.
Parameters
bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.
Return value
\Drupal\Core\TypedData\TypedDataInterface Returns itself to allow for chaining.
Overrides LanguageItem::applyDefaultValue
File
- core/modules/language/src/DefaultLanguageItem.php, line 25
Class
- DefaultLanguageItem
- Alternative plugin implementation of the 'language' field type.
Namespace
Drupal\language
Code
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(array('value' => $langcode), TRUE);
return $this;
}
Please login to continue.