3 namespace Drupal\text\Plugin\migrate\cckfield;
5 @trigger_error('TextField is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\text\Plugin\migrate\field\d6\TextField or \Drupal\text\Plugin\migrate\field\d7\TextField instead.', E_USER_DEPRECATED);
7 use Drupal\migrate\Plugin\MigrationInterface;
8 use Drupal\migrate\Row;
9 use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
16 * "text_long" = "text_long",
17 * "text_with_summary" = "text_with_summary"
20 * source_module = "text",
21 * destination_module = "text",
24 * @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
25 * \Drupal\text\Plugin\migrate\field\d6\TextField or
26 * \Drupal\text\Plugin\migrate\field\d7\TextField instead.
28 * @see https://www.drupal.org/node/2751897
30 class TextField extends CckFieldPluginBase {
35 public function getFieldWidgetMap() {
37 'text_textfield' => 'text_textfield',
44 public function getFieldFormatterMap() {
46 'default' => 'text_default',
47 'trimmed' => 'text_trimmed',
48 'plain' => 'basic_string',
55 public function processCckFieldValues(MigrationInterface $migration, $field_name, $field_info) {
56 $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type'];
58 if ($widget_type == 'optionwidgets_onoff') {
61 'plugin' => 'static_map',
67 $checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1];
68 if (strpos($checked_value, '|') !== FALSE) {
69 $checked_value = substr($checked_value, 0, strpos($checked_value, '|'));
71 $process['value']['map'][$checked_value] = 1;
74 // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
75 // signature_format for an example of the YAML that represents this
81 'plugin' => 'static_map',
87 'plugin' => 'skip_on_empty',
88 'method' => 'process',
91 'plugin' => 'migration',
103 'plugin' => 'sub_process',
104 'source' => $field_name,
105 'process' => $process,
107 $migration->setProcessOfProperty($field_name, $process);
113 public function getFieldType(Row $row) {
114 $widget_type = $row->getSourceProperty('widget_type');
115 $settings = $row->getSourceProperty('global_settings');
117 if ($widget_type == 'text_textfield') {
118 $field_type = $settings['text_processing'] ? 'text' : 'string';
119 if (empty($settings['max_length']) || $settings['max_length'] > 255) {
120 $field_type .= '_long';
125 if ($widget_type == 'text_textarea') {
126 $field_type = $settings['text_processing'] ? 'text_long' : 'string_long';
130 switch ($widget_type) {
131 case 'optionwidgets_buttons':
132 case 'optionwidgets_select':
133 return 'list_string';
134 case 'optionwidgets_onoff':
137 return parent::getFieldType($row);