3 namespace Drupal\migrate_drupal\Plugin\migrate\field;
5 use Drupal\Core\Plugin\PluginBase;
6 use Drupal\migrate\Plugin\MigrationInterface;
7 use Drupal\migrate\Row;
8 use Drupal\migrate_drupal\Plugin\MigrateFieldInterface;
11 * The base class for all field plugins.
13 * @see \Drupal\migrate\Plugin\MigratePluginManager
14 * @see \Drupal\migrate_drupal\Annotation\MigrateField
15 * @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
20 abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface {
25 public function processField(MigrationInterface $migration) {
26 $process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId;
27 $migration->mergeProcessOfProperty('type', $process);
33 public function processFieldInstance(MigrationInterface $migration) {
34 // Nothing to do by default with field instances.
40 public function processFieldWidget(MigrationInterface $migration) {
42 foreach ($this->getFieldWidgetMap() as $source_widget => $destination_widget) {
43 $process['type']['map'][$source_widget] = $destination_widget;
45 $migration->mergeProcessOfProperty('options/type', $process);
51 public function getFieldWidgetMap() {
52 // By default, use the plugin ID for the widget types.
54 $this->pluginId => $this->pluginId . '_default',
61 public function processFieldFormatter(MigrationInterface $migration) {
63 foreach ($this->getFieldFormatterMap() as $source_format => $destination_format) {
64 $process[0]['map'][$this->pluginId][$source_format] = $destination_format;
66 $migration->mergeProcessOfProperty('options/type', $process);
72 public function getFieldType(Row $row) {
73 $field_type = $row->getSourceProperty('type');
75 if (isset($this->pluginDefinition['type_map'][$field_type])) {
76 return $this->pluginDefinition['type_map'][$field_type];