You are here

public function TextField::getFieldType in Drupal 10

Same name in this branch
  1. 10 core/modules/text/src/Plugin/migrate/field/d6/TextField.php \Drupal\text\Plugin\migrate\field\d6\TextField::getFieldType()
  2. 10 core/modules/text/src/Plugin/migrate/field/d7/TextField.php \Drupal\text\Plugin\migrate\field\d7\TextField::getFieldType()
Same name and namespace in other branches
  1. 8 core/modules/text/src/Plugin/migrate/field/d6/TextField.php \Drupal\text\Plugin\migrate\field\d6\TextField::getFieldType()
  2. 9 core/modules/text/src/Plugin/migrate/field/d6/TextField.php \Drupal\text\Plugin\migrate\field\d6\TextField::getFieldType()

Computes the destination type of a migrated field.

Parameters

\Drupal\migrate\Row $row: The field being migrated.

Return value

string The destination field type.

Overrides FieldPluginBase::getFieldType

File

core/modules/text/src/Plugin/migrate/field/d6/TextField.php, line 107

Class

TextField
Plugin annotation @MigrateField( id = "d6_text", type_map = { "text" = "text", "text_long" = "text_long", "text_with_summary" = "text_with_summary" }, core = {6}, source_module = "text", destination_module = "text", )

Namespace

Drupal\text\Plugin\migrate\field\d6

Code

public function getFieldType(Row $row) {
  $widget_type = $row
    ->getSourceProperty('widget_type');
  $settings = $row
    ->getSourceProperty('global_settings');
  if ($widget_type == 'text_textfield') {
    $field_type = $settings['text_processing'] ? 'text' : 'string';
    if (empty($settings['max_length']) || $settings['max_length'] > 255) {
      $field_type .= '_long';
    }
    return $field_type;
  }
  if ($widget_type == 'text_textarea') {
    $field_type = $settings['text_processing'] ? 'text_long' : 'string_long';
    return $field_type;
  }
  switch ($widget_type) {
    case 'optionwidgets_buttons':
    case 'optionwidgets_select':
      return 'list_string';
    case 'optionwidgets_onoff':
      return 'boolean';
    default:
      return parent::getFieldType($row);
  }
}