protected function LanguageField::prepareValue in Custom Language field 8
Prepares a single value.
Parameters
int $delta: The field delta.
array $values: The values.
Overrides FieldTargetBase::prepareValue
File
- src/
Feeds/ Target/ LanguageField.php, line 33
Class
- LanguageField
- Defines a language field mapper.
Namespace
Drupal\languagefield\Feeds\TargetCode
protected function prepareValue($delta, array &$values) {
$field_definition = $this->targetDefinition
->getFieldDefinition()
->getFieldStorageDefinition();
$allowed_values = languagefield_allowed_values($field_definition);
$value = trim($values['value']);
$lang_index = array_search($value, $allowed_values);
if ($lang_index) {
$value = $lang_index;
}
$values['value'] = (string) $value;
}