public function TextFieldMapping::mapEntityField in Webform Content Creator 3.x
Use a single mapping to set an entity field value.
Overrides FieldMappingBase::mapEntityField
File
- src/
Plugin/ WebformContentCreator/ FieldMapping/ TextFieldMapping.php, line 39
Class
- TextFieldMapping
- Provides a text field mapping.
Namespace
Drupal\webform_content_creator\Plugin\WebformContentCreator\FieldMappingCode
public function mapEntityField(ContentEntityInterface &$content, array $webform_element, array $data = [], FieldDefinitionInterface $field_definition) {
$field_id = $field_definition
->getName();
$field_value = $data[$field_id];
$max_length = $this
->checkMaxFieldSizeExceeded($field_definition, $field_value);
if ($max_length === 0) {
$content
->set($field_id, $field_value);
}
else {
$content
->set($field_id, substr($field_value, 0, $max_length));
}
}