function FieldType::transform

Same name and namespace in other branches
  1. 11.x core/modules/field/src/Plugin/migrate/process/FieldType.php \Drupal\field\Plugin\migrate\process\FieldType::transform()
  2. 10 core/modules/field/src/Plugin/migrate/process/FieldType.php \Drupal\field\Plugin\migrate\process\FieldType::transform()
  3. 9 core/modules/field/src/Plugin/migrate/process/FieldType.php \Drupal\field\Plugin\migrate\process\FieldType::transform()
  4. main core/modules/field/src/Plugin/migrate/process/FieldType.php \Drupal\field\Plugin\migrate\process\FieldType::transform()

Overrides StaticMap::transform

File

core/modules/field/src/Plugin/migrate/process/FieldType.php, line 83

Class

FieldType
Plugin annotation @MigrateProcessPlugin( id = "field_type" )

Namespace

Drupal\field\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
  $field_type = is_array($value) ? $value[0] : $value;
  try {
    $plugin_id = $this->fieldPluginManager
      ->getPluginIdFromFieldType($field_type, [], $this->migration);
    return $this->fieldPluginManager
      ->createInstance($plugin_id, [], $this->migration)
      ->getFieldType($row);
  } catch (PluginNotFoundException $e) {
    try {
      $plugin_id = $this->cckPluginManager
        ->getPluginIdFromFieldType($field_type, [], $this->migration);
      return $this->cckPluginManager
        ->createInstance($plugin_id, [], $this->migration)
        ->getFieldType($row);
    } catch (PluginNotFoundException $e) {
      return parent::transform($value, $migrate_executable, $row, $destination_property);
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.