3 namespace Drupal\text\Plugin\migrate\cckfield;
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\migrate\Row;
7 use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
14 * "text_long" = "text_long",
15 * "text_with_summary" = "text_with_summary"
20 class TextField extends CckFieldPluginBase {
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 processCckFieldValues(MigrationInterface $migration, $field_name, $field_info) {
46 if ($field_info['widget_type'] == 'optionwidgets_onoff') {
49 'plugin' => 'static_map',
55 $checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1];
56 if (strpos($checked_value, '|') !== FALSE) {
57 $checked_value = substr($checked_value, 0, strpos($checked_value, '|'));
59 $process['value']['map'][$checked_value] = 1;
62 // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
63 // signature_format for an example of the YAML that represents this
69 'plugin' => 'static_map',
75 'plugin' => 'skip_on_empty',
76 'method' => 'process',
79 'plugin' => 'migration',
91 'plugin' => 'iterator',
92 'source' => $field_name,
93 'process' => $process,
95 $migration->setProcessOfProperty($field_name, $process);
101 public function getFieldType(Row $row) {
102 $widget_type = $row->getSourceProperty('widget_type');
103 $settings = $row->getSourceProperty('global_settings');
105 if ($widget_type == 'text_textfield') {
106 $field_type = $settings['text_processing'] ? 'text' : 'string';
107 if (empty($settings['max_length']) || $settings['max_length'] > 255) {
108 $field_type .= '_long';
113 if ($widget_type == 'text_textarea') {
114 $field_type = $settings['text_processing'] ? 'text_long' : 'string_long';
118 switch ($widget_type) {
119 case 'optionwidgets_buttons':
120 case 'optionwidgets_select':
121 return 'list_string';
122 case 'optionwidgets_onoff':
125 return parent::getFieldType($row);