FieldPluginBase.php in Drupal 10
File
core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php
View source
<?php
namespace Drupal\migrate_drupal\Plugin\migrate\field;
use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\MigrateFieldInterface;
abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface {
public function alterFieldMigration(MigrationInterface $migration) {
$process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId;
$migration
->mergeProcessOfProperty('type', $process);
}
public function alterFieldInstanceMigration(MigrationInterface $migration) {
}
public function alterFieldWidgetMigration(MigrationInterface $migration) {
$process = [];
foreach ($this
->getFieldWidgetMap() as $source_widget => $destination_widget) {
$process['type']['map'][$source_widget] = $destination_widget;
}
$migration
->mergeProcessOfProperty('options/type', $process);
}
public function getFieldFormatterType(Row $row) {
return $row
->getSourceProperty('formatter/type');
}
public function getFieldFormatterMap() {
return [];
}
public function getFieldWidgetType(Row $row) {
return $row
->getSourceProperty('widget/type');
}
public function getFieldWidgetMap() {
return [
$this->pluginId => $this->pluginId . '_default',
];
}
public function alterFieldFormatterMigration(MigrationInterface $migration) {
$process = [];
$plugin_id = preg_replace('/d[67]_/', '', $this->pluginId);
foreach ($this
->getFieldFormatterMap() as $source_format => $destination_format) {
$process[0]['map'][$plugin_id][$source_format] = $destination_format;
}
$migration
->mergeProcessOfProperty('options/type', $process);
}
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'get',
'source' => $field_name,
];
$migration
->mergeProcessOfProperty($field_name, $process);
}
public function getFieldType(Row $row) {
$field_type = $row
->getSourceProperty('type');
if (isset($this->pluginDefinition['type_map'][$field_type])) {
return $this->pluginDefinition['type_map'][$field_type];
}
else {
return $field_type;
}
}
}