3 namespace Drupal\text\Plugin\migrate\field\d6;
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\migrate\Row;
7 use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
14 * "text_long" = "text_long",
15 * "text_with_summary" = "text_with_summary"
20 class TextField extends FieldPluginBase {
25 public function getFieldWidgetMap() {
27 'text_textfield' => 'text_textfield',
34 public function getFieldFormatterMap() {
36 'default' => 'text_default',
37 'trimmed' => 'text_trimmed',
38 'plain' => 'basic_string',
45 public function processFieldValues(MigrationInterface $migration, $field_name, $field_info) {
46 $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type'];
48 if ($widget_type == 'optionwidgets_onoff') {
51 'plugin' => 'static_map',
57 $checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1];
58 if (strpos($checked_value, '|') !== FALSE) {
59 $checked_value = substr($checked_value, 0, strpos($checked_value, '|'));
61 $process['value']['map'][$checked_value] = 1;
64 // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
65 // signature_format for an example of the YAML that represents this
71 'plugin' => 'static_map',
77 'plugin' => 'skip_on_empty',
78 'method' => 'process',
81 'plugin' => 'migration',
93 'plugin' => 'sub_process',
94 'source' => $field_name,
95 'process' => $process,
97 $migration->setProcessOfProperty($field_name, $process);
103 public function getFieldType(Row $row) {
104 $widget_type = $row->getSourceProperty('widget_type');
105 $settings = $row->getSourceProperty('global_settings');
107 if ($widget_type == 'text_textfield') {
108 $field_type = $settings['text_processing'] ? 'text' : 'string';
109 if (empty($settings['max_length']) || $settings['max_length'] > 255) {
110 $field_type .= '_long';
115 if ($widget_type == 'text_textarea') {
116 $field_type = $settings['text_processing'] ? 'text_long' : 'string_long';
120 switch ($widget_type) {
121 case 'optionwidgets_buttons':
122 case 'optionwidgets_select':
123 return 'list_string';
124 case 'optionwidgets_onoff':
127 return parent::getFieldType($row);