You are here

public function DateTimeFieldMapping::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/DateTimeFieldMapping.php, line 40

Class

DateTimeFieldMapping
Provides a datetime field mapping.

Namespace

Drupal\webform_content_creator\Plugin\WebformContentCreator\FieldMapping

Code

public function mapEntityField(ContentEntityInterface &$content, array $webform_element, array $data = [], FieldDefinitionInterface $field_definition) {
  $field_id = $field_definition
    ->getName();
  $field_value = $data[$field_id];
  if ($field_definition
    ->getType() == "datetime") {
    $field_data = $this
      ->convertTimestamp($field_value, $field_definition);
    $content
      ->set($field_id, $field_data);
  }
}