You are here

public function TextField::getFieldFormatterType in Drupal 10

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

Get the field formatter type from the source.

Parameters

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

Return value

string The field formatter type.

Overrides FieldPluginBase::getFieldFormatterType

File

core/modules/text/src/Plugin/migrate/field/d7/TextField.php, line 27

Class

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

Namespace

Drupal\text\Plugin\migrate\field\d7

Code

public function getFieldFormatterType(Row $row) {
  $field_type = $this
    ->getFieldType($row);
  $formatter_type = $row
    ->getSourceProperty('formatter/type');
  switch ($field_type) {
    case 'string':
      $formatter_type = str_replace([
        'text_default',
        'text_plain',
      ], 'string', $formatter_type);
      break;
    case 'string_long':
      $formatter_type = str_replace([
        'text_default',
        'text_plain',
      ], 'basic_string', $formatter_type);
      break;
  }
  return $formatter_type;
}