function Language::setValue
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language::setValue()
- 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language::setValue()
- 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php \Drupal\Core\TypedData\Plugin\DataType\Language::setValue()
Overrides TypedData::setValue().
Both the langcode and the language object may be passed as value.
Overrides TypedData::setValue
File
-
core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ Language.php, line 51
Class
- Language
- Defines the 'language' data type.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function setValue($value, $notify = TRUE) {
// Support passing language objects.
if (is_object($value)) {
$this->id = $value->getId();
$this->language = $value;
}
elseif (isset($value) && !is_scalar($value)) {
throw new \InvalidArgumentException('Value is no valid langcode or language object.');
}
else {
$this->id = $value;
$this->language = NULL;
}
// Notify the parent of any changes.
if ($notify && isset($this->parent)) {
$this->parent
->onChange($this->name);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.