diff --git a/core/modules/field/migration_templates/d7_field_formatter_settings.yml b/core/modules/field/migration_templates/d7_field_formatter_settings.yml index 126fd29..3055e47 100644 --- a/core/modules/field/migration_templates/d7_field_formatter_settings.yml +++ b/core/modules/field/migration_templates/d7_field_formatter_settings.yml @@ -44,14 +44,14 @@ process: map: full: default field_name: field_name - "options/label": label - "options/weight": weight + "options/label": 'formatter/label' + "options/weight": 'formatter/weight' # The formatter to use. "options/type": - plugin: static_map bypass: true - source: formatter_type + source: 'formatter/type' map: date_default: datetime_default email_default: email_mailto @@ -69,7 +69,7 @@ process: method: row "options/settings": plugin: default_value - source: settings + source: 'formatter/settings' default_value: [] "options/third_party_settings": 'constants/third_party_settings' destination: diff --git a/core/modules/field/migration_templates/d7_field_instance.yml b/core/modules/field/migration_templates/d7_field_instance.yml index f3518c9..03e77cd 100644 --- a/core/modules/field/migration_templates/d7_field_instance.yml +++ b/core/modules/field/migration_templates/d7_field_instance.yml @@ -19,15 +19,15 @@ process: settings: plugin: d7_field_instance_settings source: - - instance_settings - - widget_settings - - field_settings + - settings + - widget + - field_definition default_value_function: '' default_value: plugin: d7_field_instance_defaults source: - default_value - - widget_settings + - widget translatable: translatable destination: plugin: entity:field_config diff --git a/core/modules/field/migration_templates/d7_field_instance_widget_settings.yml b/core/modules/field/migration_templates/d7_field_instance_widget_settings.yml index e2bbcf4..85a67cb 100644 --- a/core/modules/field/migration_templates/d7_field_instance_widget_settings.yml +++ b/core/modules/field/migration_templates/d7_field_instance_widget_settings.yml @@ -52,7 +52,7 @@ process: plugin: field_instance_widget_settings source: - 'widget/type' - - widget_settings + - 'widget/settings' 'options/third_party_settings': 'constants/third_party_settings' destination: plugin: component_entity_form_display diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php index 2a46381..a6707bd 100644 --- a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php +++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceDefaults.php @@ -19,6 +19,11 @@ class FieldInstanceDefaults extends ProcessPluginBase { public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { list($default_value, $widget_settings) = $value; $widget_type = $widget_settings['type']; + $default_value = $default_value ?: []; + if ($widget_type == 'email_textfield' && $default_value) { + $default_value[0]['value'] = $default_value[0]['email']; + unset($default_value[0]['email']); + } $default = []; diff --git a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php index 70a9498..991ce09c 100644 --- a/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php +++ b/core/modules/field/src/Plugin/migrate/process/d7/FieldInstanceSettings.php @@ -17,9 +17,12 @@ class FieldInstanceSettings extends ProcessPluginBase { * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - list($instance_settings, $widget_settings, $field_settings) = $value; + list($instance_settings, $widget_settings, $field_definition) = $value; $widget_type = $widget_settings['type']; + $field_data = unserialize($field_definition['data']); + $field_settings = $field_data['settings']; + // Get entityreference handler settings from source field configuration. if ($row->getSourceProperty('type') == "entityreference") { $instance_settings['handler'] = 'default:' . $field_settings['target_type']; diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php index d06336e..8b86a94 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php @@ -8,6 +8,11 @@ /** * Drupal 7 field instances source from database. * + * @internal + * + * This class is marked as internal and should not be extended. Use + * Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase instead. + * * @MigrateSource( * id = "d7_field_instance", * source_provider = "field" @@ -21,14 +26,12 @@ class FieldInstance extends DrupalSqlBase { public function query() { $query = $this->select('field_config_instance', 'fci') ->fields('fci') - ->condition('fci.deleted', 0) + ->fields('fc', ['type']) ->condition('fc.active', 1) - ->condition('fc.deleted', 0) ->condition('fc.storage_active', 1) - ->fields('fc', ['type']); - - $query->innerJoin('field_config', 'fc', 'fci.field_id = fc.id'); - $query->addField('fc', 'data', 'field_data'); + ->condition('fc.deleted', 0) + ->condition('fci.deleted', 0); + $query->join('field_config', 'fc', 'fci.field_id = fc.id'); // Optionally filter by entity type and bundle. if (isset($this->configuration['entity_type'])) { @@ -45,16 +48,39 @@ public function query() { /** * {@inheritdoc} */ + protected function initializeIterator() { + $results = $this->prepareQuery()->execute()->fetchAll(); + + // Group all instances by their base field. + $instances = []; + foreach ($results as $result) { + $instances[$result['field_id']][] = $result; + } + + // Add the array of all instances using the same base field to each row. + $rows = []; + foreach ($results as $result) { + $result['instances'] = $instances[$result['field_id']]; + $rows[] = $result; + } + + return new \ArrayIterator($rows); + } + + /** + * {@inheritdoc} + */ public function fields() { return [ - 'field_name' => $this->t('The machine name of field.'), + 'id' => $this->t('The field instance ID.'), + 'field_id' => $this->t('The field ID.'), + 'field_name' => $this->t('The field name.'), 'entity_type' => $this->t('The entity type.'), 'bundle' => $this->t('The entity bundle.'), - 'default_value' => $this->t('Default value'), - 'instance_settings' => $this->t('Field instance settings.'), - 'widget_settings' => $this->t('Widget settings.'), - 'display_settings' => $this->t('Display settings.'), - 'field_settings' => $this->t('Field settings.'), + 'data' => $this->t('The field instance data.'), + 'deleted' => $this->t('Deleted'), + 'type' => $this->t('The field type'), + 'field_definition' => $this->t('The field definition.'), ]; } @@ -62,29 +88,16 @@ public function fields() { * {@inheritdoc} */ public function prepareRow(Row $row) { - $data = unserialize($row->getSourceProperty('data')); - - $row->setSourceProperty('label', $data['label']); - $row->setSourceProperty('description', $data['description']); - $row->setSourceProperty('required', $data['required']); - - $default_value = !empty($data['default_value']) ? $data['default_value'] : []; - if ($data['widget']['type'] == 'email_textfield' && $default_value) { - $default_value[0]['value'] = $default_value[0]['email']; - unset($default_value[0]['email']); + foreach (unserialize($row->getSourceProperty('data')) as $key => $value) { + $row->setSourceProperty($key, $value); } - $row->setSourceProperty('default_value', $default_value); - - // Settings. - $row->setSourceProperty('instance_settings', $data['settings']); - $row->setSourceProperty('widget_settings', $data['widget']); - $row->setSourceProperty('display_settings', $data['display']); - // This is for parity with the d6_field_instance plugin. - $row->setSourceProperty('widget_type', $data['widget']['type']); - - $field_data = unserialize($row->getSourceProperty('field_data')); - $row->setSourceProperty('field_settings', $field_data['settings']); + $field_definition = $this->select('field_config', 'fc') + ->fields('fc') + ->condition('id', $row->getSourceProperty('field_id')) + ->execute() + ->fetch(); + $row->setSourceProperty('field_definition', $field_definition); $translatable = FALSE; if ($row->getSourceProperty('entity_type') == 'node') { @@ -100,8 +113,8 @@ public function prepareRow(Row $row) { else { // This is not a node entity. Get the translatable value from the source // field_config table. - $data = unserialize($row->getSourceProperty('field_data')); - $translatable = $data['translatable']; + $field_data = unserialize($field_definition['data']); + $translatable = $field_data['translatable']; } $row->setSourceProperty('translatable', $translatable); @@ -128,4 +141,11 @@ public function getIds() { ]; } + /** + * {@inheritdoc} + */ + public function count() { + return $this->initializeIterator()->count(); + } + } diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php index ac599ec..575f61f 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerFormDisplay.php @@ -2,58 +2,15 @@ namespace Drupal\field\Plugin\migrate\source\d7; -use Drupal\migrate\Row; -use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; - /** * The field instance per form display source class. * * @MigrateSource( - * id = "d7_field_instance_per_form_display" + * id = "d7_field_instance_per_form_display", + * source_provider = "field" * ) */ -class FieldInstancePerFormDisplay extends DrupalSqlBase { - - /** - * {@inheritdoc} - */ - public function query() { - $query = $this->select('field_config_instance', 'fci') - ->fields('fci', [ - 'field_name', - 'bundle', - 'data', - 'entity_type' - ]) - ->fields('fc', [ - 'type', - 'module', - ]); - $query->join('field_config', 'fc', 'fci.field_id = fc.id'); - return $query; - } - - /** - * {@inheritdoc} - */ - public function prepareRow(Row $row) { - $data = unserialize($row->getSourceProperty('data')); - $row->setSourceProperty('widget', $data['widget']); - $row->setSourceProperty('widget_settings', $data['widget']['settings']); - return parent::prepareRow($row); - } - - /** - * {@inheritdoc} - */ - public function fields() { - return [ - 'field_name' => $this->t('The machine name of field.'), - 'bundle' => $this->t('Content type where this field is used.'), - 'data' => $this->t('Field configuration data.'), - 'entity_type' => $this->t('The entity type.'), - ]; - } +class FieldInstancePerFormDisplay extends FieldInstance { /** * {@inheritdoc} diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php index 7339e76..131c954 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php @@ -2,8 +2,6 @@ namespace Drupal\field\Plugin\migrate\source\d7; -use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; - /** * The field instance per view mode source class. * @@ -12,26 +10,21 @@ * source_provider = "field" * ) */ -class FieldInstancePerViewMode extends DrupalSqlBase { +class FieldInstancePerViewMode extends FieldInstance { /** * {@inheritdoc} */ protected function initializeIterator() { - $rows = []; - $result = $this->prepareQuery()->execute(); - foreach ($result as $field_instance) { - $data = unserialize($field_instance['data']); - // We don't need to include the serialized data in the returned rows. - unset($field_instance['data']); + $instances = parent::initializeIterator(); - foreach ($data['display'] as $view_mode => $info) { - // Rename type to formatter_type in the info array. - $info['formatter_type'] = $info['type']; - unset($info['type']); - - $rows[] = array_merge($field_instance, $info, [ + $rows = []; + foreach ($instances->getArrayCopy() as $instance) { + $data = unserialize($instance['data']); + foreach ($data['display'] as $view_mode => $formatter) { + $rows[] = array_merge($instance, [ 'view_mode' => $view_mode, + 'formatter' => $formatter, ]); } } @@ -41,30 +34,11 @@ protected function initializeIterator() { /** * {@inheritdoc} */ - public function query() { - $query = $this->select('field_config_instance', 'fci') - ->fields('fci', ['entity_type', 'bundle', 'field_name', 'data']) - ->fields('fc', ['type']); - $query->join('field_config', 'fc', 'fc.field_name = fci.field_name'); - return $query; - } - - /** - * {@inheritdoc} - */ public function fields() { - return [ - 'entity_type' => $this->t('The entity type ID.'), - 'bundle' => $this->t('The bundle ID.'), - 'field_name' => $this->t('Machine name of the field.'), + return array_merge(parent::fields(), [ 'view_mode' => $this->t('The original machine name of the view mode.'), - 'label' => $this->t('The display label of the field.'), - 'type' => $this->t('The field ID.'), - 'formatter_type' => $this->t('The formatter ID.'), - 'settings' => $this->t('Array of formatter-specific settings.'), - 'module' => $this->t('The module providing the formatter.'), - 'weight' => $this->t('Display weight of the field.'), - ]; + 'formatter' => $this->t('The formatter settings.'), + ]); } /** @@ -87,11 +61,4 @@ public function getIds() { ]; } - /** - * {@inheritdoc} - */ - public function count() { - return $this->initializeIterator()->count(); - } - } diff --git a/core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php b/core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php index 3dd037c..cd2ce82 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php @@ -2,31 +2,33 @@ namespace Drupal\field\Plugin\migrate\source\d7; -use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; - /** + * The view mode source class. + * * @MigrateSource( - * id = "d7_view_mode" + * id = "d7_view_mode", + * source_provider = "field" * ) */ -class ViewMode extends DrupalSqlBase { +class ViewMode extends FieldInstance { /** * {@inheritdoc} */ protected function initializeIterator() { + $instances = parent::initializeIterator(); + $rows = []; - $result = $this->prepareQuery()->execute(); - foreach ($result as $field_instance) { - $data = unserialize($field_instance['data']); + foreach ($instances->getArrayCopy() as $instance) { + $data = unserialize($instance['data']); foreach (array_keys($data['display']) as $view_mode) { - $key = $field_instance['entity_type'] . '.' . $view_mode; - $rows[$key] = [ - 'entity_type' => $field_instance['entity_type'], + $key = $instance['entity_type'] . '.' . $view_mode; + $rows[$key] = array_merge($instance, [ 'view_mode' => $view_mode, - ]; + ]); } } + return new \ArrayIterator($rows); } @@ -34,18 +36,9 @@ protected function initializeIterator() { * {@inheritdoc} */ public function fields() { - return [ + return array_merge(parent::fields(), [ 'view_mode' => $this->t('The view mode ID.'), - 'entity_type' => $this->t('The entity type ID.'), - ]; - } - - /** - * {@inheritdoc} - */ - public function query() { - return $this->select('field_config_instance', 'fci') - ->fields('fci', ['entity_type', 'data']); + ]); } /** @@ -62,11 +55,4 @@ public function getIds() { ]; } - /** - * {@inheritdoc} - */ - public function count() { - return $this->initializeIterator()->count(); - } - } diff --git a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerFormDisplayTest.php b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerFormDisplayTest.php index e2de4fd..0663b91 100644 --- a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerFormDisplayTest.php +++ b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerFormDisplayTest.php @@ -133,33 +133,184 @@ public function providerSource() { // The expected results. $tests[0]['expected_data'] = [ [ + 'id' => '2', + 'field_id' => '2', 'field_name' => 'body', 'entity_type' => 'node', 'bundle' => 'page', - 'widget_settings' => [ - 'rows' => 20, - 'summary_rows' => 5, + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'text_with_summary', + 'widget' => [ + 'module' => 'text', + 'settings' => [ + 'rows' => 20, + 'summary_rows' => 5, + ], + 'type' => 'text_textarea_with_summary', + 'weight' => -4, + ], + 'field_definition' => [ + 'id' => '2', + 'field_name' => 'body', + 'type' => 'text_with_summary', + 'module' => 'text', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '2', + 'field_id' => '2', + 'field_name' => 'body', + 'entity_type' => 'node', + 'bundle' => 'page', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'text_with_summary', + ], ], ], [ + 'id' => '33', + 'field_id' => '11', 'field_name' => 'field_file', 'entity_type' => 'user', 'bundle' => 'user', - 'widget_settings' => [ - 'progress_indicator' => 'throbber', + 'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"8";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:3:"txt";s:12:"max_filesize";s:0:"";s:17:"description_field";i:0;s:18:"user_register_form";i:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:8:"settings";a:0:{}s:6:"module";s:4:"file";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'file', + 'widget' => [ + 'active' => 1, + 'module' => 'file', + 'settings' => [ + 'progress_indicator' => 'throbber', + ], + 'type' => 'file_generic', + 'weight' => '8', + ], + 'field_definition' => [ + 'id' => '11', + 'field_name' => 'field_file', + 'type' => 'file', + 'module' => 'file', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:13:"display_field";i:0;s:15:"display_default";i:0;s:10:"uri_scheme";s:6:"public";}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:21:"field_data_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:25:"field_revision_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}}}}s:12:"foreign keys";a:1:{s:3:"fid";a:2:{s:5:"table";s:12:"file_managed";s:7:"columns";a:1:{s:3:"fid";s:3:"fid";}}}s:7:"indexes";a:1:{s:3:"fid";a:1:{i:0;s:3:"fid";}}s:2:"id";s:2:"11";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '33', + 'field_id' => '11', + 'field_name' => 'field_file', + 'entity_type' => 'user', + 'bundle' => 'user', + 'data' => 'a:6:{s:5:"label";s:4:"File";s:6:"widget";a:5:{s:6:"weight";s:1:"8";s:4:"type";s:12:"file_generic";s:6:"module";s:4:"file";s:6:"active";i:1;s:8:"settings";a:1:{s:18:"progress_indicator";s:8:"throbber";}}s:8:"settings";a:5:{s:14:"file_directory";s:0:"";s:15:"file_extensions";s:3:"txt";s:12:"max_filesize";s:0:"";s:17:"description_field";i:0;s:18:"user_register_form";i:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"file_default";s:8:"settings";a:0:{}s:6:"module";s:4:"file";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'file', + ], ], ], [ + 'id' => '32', + 'field_id' => '14', 'field_name' => 'field_integer', 'entity_type' => 'comment', 'bundle' => 'comment_node_test_content_type', - 'widget_settings' => [], + 'data' => 'a:7:{s:5:"label";s:7:"Integer";s:6:"widget";a:5:{s:6:"weight";s:1:"2";s:4:"type";s:6:"number";s:6:"module";s:6:"number";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:5:{s:3:"min";s:0:"";s:3:"max";s:0:"";s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:14:"number_integer";s:8:"settings";a:4:{s:18:"thousand_separator";s:1:" ";s:17:"decimal_separator";s:1:".";s:5:"scale";i:0;s:13:"prefix_suffix";b:1;}s:6:"module";s:6:"number";s:6:"weight";i:1;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', + 'deleted' => '0', + 'type' => 'number_integer', + 'widget' => [ + 'weight' => '2', + 'type' => 'number', + 'module' => 'number', + 'active' => 0, + 'settings' => [], + ], + 'field_definition' => [ + 'id' => '14', + 'field_name' => 'field_integer', + 'type' => 'number_integer', + 'module' => 'number', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:0:{}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:24:"field_data_field_integer";a:1:{s:5:"value";s:19:"field_integer_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:28:"field_revision_field_integer";a:1:{s:5:"value";s:19:"field_integer_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:0:{}s:2:"id";s:2:"14";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '32', + 'field_id' => '14', + 'field_name' => 'field_integer', + 'entity_type' => 'comment', + 'bundle' => 'comment_node_test_content_type', + 'data' => 'a:7:{s:5:"label";s:7:"Integer";s:6:"widget";a:5:{s:6:"weight";s:1:"2";s:4:"type";s:6:"number";s:6:"module";s:6:"number";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:5:{s:3:"min";s:0:"";s:3:"max";s:0:"";s:6:"prefix";s:0:"";s:6:"suffix";s:0:"";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:14:"number_integer";s:8:"settings";a:4:{s:18:"thousand_separator";s:1:" ";s:17:"decimal_separator";s:1:".";s:5:"scale";i:0;s:13:"prefix_suffix";b:1;}s:6:"module";s:6:"number";s:6:"weight";i:1;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', + 'deleted' => '0', + 'type' => 'number_integer', + ] + ], ], [ + 'id' => '25', + 'field_id' => '15', 'field_name' => 'field_link', 'entity_type' => 'taxonomy_term', 'bundle' => 'test_vocabulary', - 'widget_settings' => [], + 'data' => 'a:7:{s:5:"label";s:4:"Link";s:6:"widget";a:5:{s:6:"weight";s:2:"10";s:4:"type";s:10:"link_field";s:6:"module";s:4:"link";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:12:{s:12:"absolute_url";i:1;s:12:"validate_url";i:1;s:3:"url";i:0;s:5:"title";s:8:"optional";s:11:"title_value";s:19:"Unused Static Title";s:27:"title_label_use_field_label";i:0;s:15:"title_maxlength";s:3:"128";s:7:"display";a:1:{s:10:"url_cutoff";s:2:"81";}s:10:"attributes";a:6:{s:6:"target";s:6:"_blank";s:3:"rel";s:8:"nofollow";s:18:"configurable_class";i:0;s:5:"class";s:7:"classes";s:18:"configurable_title";i:1;s:5:"title";s:0:"";}s:10:"rel_remove";s:19:"rel_remove_external";s:13:"enable_tokens";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"link_default";s:6:"weight";s:1:"9";s:8:"settings";a:0:{}s:6:"module";s:4:"link";}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', + 'deleted' => '0', + 'type' => 'link_field', + 'widget' => [ + 'weight' => '10', + 'type' => 'link_field', + 'module' => 'link', + 'active' => 0, + 'settings' => [], + ], + 'field_definition' => [ + 'id' => '15', + 'field_name' => 'field_link', + 'type' => 'link_field', + 'module' => 'link', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:7:{s:10:"attributes";a:3:{s:6:"target";s:7:"default";s:5:"class";s:0:"";s:3:"rel";s:0:"";}s:3:"url";i:0;s:5:"title";s:8:"optional";s:11:"title_value";s:0:"";s:15:"title_maxlength";i:128;s:13:"enable_tokens";i:1;s:7:"display";a:1:{s:10:"url_cutoff";i:80;}}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:21:"field_data_field_link";a:3:{s:3:"url";s:14:"field_link_url";s:5:"title";s:16:"field_link_title";s:10:"attributes";s:21:"field_link_attributes";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:25:"field_revision_field_link";a:3:{s:3:"url";s:14:"field_link_url";s:5:"title";s:16:"field_link_title";s:10:"attributes";s:21:"field_link_attributes";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:0:{}s:2:"id";s:2:"15";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '25', + 'field_id' => '15', + 'field_name' => 'field_link', + 'entity_type' => 'taxonomy_term', + 'bundle' => 'test_vocabulary', + 'data' => 'a:7:{s:5:"label";s:4:"Link";s:6:"widget";a:5:{s:6:"weight";s:2:"10";s:4:"type";s:10:"link_field";s:6:"module";s:4:"link";s:6:"active";i:0;s:8:"settings";a:0:{}}s:8:"settings";a:12:{s:12:"absolute_url";i:1;s:12:"validate_url";i:1;s:3:"url";i:0;s:5:"title";s:8:"optional";s:11:"title_value";s:19:"Unused Static Title";s:27:"title_label_use_field_label";i:0;s:15:"title_maxlength";s:3:"128";s:7:"display";a:1:{s:10:"url_cutoff";s:2:"81";}s:10:"attributes";a:6:{s:6:"target";s:6:"_blank";s:3:"rel";s:8:"nofollow";s:18:"configurable_class";i:0;s:5:"class";s:7:"classes";s:18:"configurable_title";i:1;s:5:"title";s:0:"";}s:10:"rel_remove";s:19:"rel_remove_external";s:13:"enable_tokens";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"link_default";s:6:"weight";s:1:"9";s:8:"settings";a:0:{}s:6:"module";s:4:"link";}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}', + 'deleted' => '0', + 'type' => 'link_field', + ], + ], ], ]; diff --git a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php index ff5993e..e3faee4 100644 --- a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php +++ b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php @@ -62,30 +62,96 @@ public function providerSource() { // The expected results. $tests[0]['expected_data'] = [ [ + 'id' => '2', + 'field_id' => '2', + 'field_name' => 'body', 'entity_type' => 'node', 'bundle' => 'page', - 'field_name' => 'body', - 'label' => 'hidden', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', 'type' => 'text_with_summary', - 'formatter_type' => 'text_default', - 'settings' => [], - 'module' => 'text', - 'weight' => 0, 'view_mode' => 'default', + 'formatter' => [ + 'label' => 'hidden', + 'type' => 'text_default', + 'settings' => [], + 'module' => 'text', + 'weight' => 0, + ], + 'field_definition' => [ + 'id' => '2', + 'field_name' => 'body', + 'type' => 'text_with_summary', + 'module' => 'text', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";}s:2:"id";s:2:"25";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '2', + 'field_id' => '2', + 'field_name' => 'body', + 'entity_type' => 'node', + 'bundle' => 'page', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'text_with_summary', + ], + ], ], [ + 'id' => '2', + 'field_id' => '2', + 'field_name' => 'body', 'entity_type' => 'node', 'bundle' => 'page', - 'field_name' => 'body', - 'label' => 'hidden', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', 'type' => 'text_with_summary', - 'formatter_type' => 'text_summary_or_trimmed', - 'settings' => [ - 'trim_length' => 600, + 'formatter' => [ + 'label' => 'hidden', + 'type' => 'text_summary_or_trimmed', + 'settings' => [ + 'trim_length' => 600, + ], + 'module' => 'text', + 'weight' => 0, ], - 'module' => 'text', - 'weight' => 0, 'view_mode' => 'teaser', + 'field_definition' => [ + 'id' => '2', + 'field_name' => 'body', + 'type' => 'text_with_summary', + 'module' => 'text', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";}s:2:"id";s:2:"25";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '2', + 'field_id' => '2', + 'field_name' => 'body', + 'entity_type' => 'node', + 'bundle' => 'page', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'text_with_summary', + ], + ], ], ]; diff --git a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php index c9e93ef..895fe3f 100644 --- a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php +++ b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstanceTest.php @@ -61,20 +61,30 @@ public function providerSource() { // The expected results. $tests[0]['expected_data'] = [ [ + 'id' => '2', + 'field_id' => '2', 'field_name' => 'body', 'entity_type' => 'node', 'bundle' => 'page', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'text_with_summary', 'label' => 'Body', - 'widget_settings' => [ - 'module' => 'text', + 'widget' => [ + 'type' => 'text_textarea_with_summary', 'settings' => [ 'rows' => 20, 'summary_rows' => 5, ], - 'type' => 'text_textarea_with_summary', 'weight' => -4, + 'module' => 'text', + ], + 'settings' => [ + 'display_summary' => TRUE, + 'text_processing' => '1', + 'user_register_form' => FALSE, ], - 'display_settings' => [ + 'display' => [ 'default' => [ 'label' => 'hidden', 'type' => 'text_default', @@ -92,9 +102,35 @@ public function providerSource() { 'weight' => 0, ], ], - 'description' => '', 'required' => FALSE, - 'field_data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}', + 'description' => '', + 'field_definition' => [ + 'id' => '2', + 'field_name' => 'body', + 'type' => 'text_with_summary', + 'module' => 'text', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + 'instances' => [ + [ + 'id' => '2', + 'field_id' => '2', + 'field_name' => 'body', + 'entity_type' => 'node', + 'bundle' => 'page', + 'data' => 'a:6:{s:5:"label";s:4:"Body";s:6:"widget";a:4:{s:4:"type";s:26:"text_textarea_with_summary";s:8:"settings";a:2:{s:4:"rows";i:20;s:12:"summary_rows";i:5;}s:6:"weight";i:-4;s:6:"module";s:4:"text";}s:8:"settings";a:3:{s:15:"display_summary";b:1;s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:7:"display";a:2:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}s:6:"teaser";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:23:"text_summary_or_trimmed";s:8:"settings";a:1:{s:11:"trim_length";i:600;}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";b:0;s:11:"description";s:0:"";}', + 'deleted' => '0', + 'type' => 'text_with_summary', + ], + ], ], ]; diff --git a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/ViewModeTest.php b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/ViewModeTest.php index 42c7bce..deab066 100644 --- a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/ViewModeTest.php +++ b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/ViewModeTest.php @@ -50,14 +50,46 @@ public function providerSource() { ], [ 'id' => '12', - 'field_id' => '1', - 'field_name' => 'comment_body', + 'field_id' => '2', + 'field_name' => 'body', 'entity_type' => 'comment', 'bundle' => 'comment_node_forum', 'data' => 'a:6:{s:5:"label";s:7:"Comment";s:8:"settings";a:2:{s:15:"text_processing";i:1;s:18:"user_register_form";b:0;}s:8:"required";b:1;s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:6:"hidden";s:4:"type";s:12:"text_default";s:6:"weight";i:0;s:8:"settings";a:0:{}s:6:"module";s:4:"text";}}s:6:"widget";a:4:{s:4:"type";s:13:"text_textarea";s:8:"settings";a:1:{s:4:"rows";i:5;}s:6:"weight";i:0;s:6:"module";s:4:"text";}s:11:"description";s:0:"";}', 'deleted' => '0', ], ]; + $tests[0]['source_data']['field_config'] = [ + [ + 'id' => '2', + 'field_name' => 'body', + 'type' => 'text_with_summary', + 'module' => 'text', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + [ + 'id' => '11', + 'field_name' => 'field_file', + 'type' => 'file', + 'module' => 'file', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"translatable";s:1:"0";s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:13:"display_field";i:0;s:15:"display_default";i:0;s:10:"uri_scheme";s:6:"public";}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:21:"field_data_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:25:"field_revision_field_file";a:3:{s:3:"fid";s:14:"field_file_fid";s:7:"display";s:18:"field_file_display";s:11:"description";s:22:"field_file_description";}}}}}s:12:"foreign keys";a:1:{s:3:"fid";a:2:{s:5:"table";s:12:"file_managed";s:7:"columns";a:1:{s:3:"fid";s:3:"fid";}}}s:7:"indexes";a:1:{s:3:"fid";a:1:{i:0;s:3:"fid";}}s:2:"id";s:2:"11";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + ]; // The expected results. $tests[0]['expected_data'] = [ diff --git a/core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldInstanceSettingsTest.php b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldInstanceSettingsTest.php index 8c405b0..115ff48 100644 --- a/core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldInstanceSettingsTest.php +++ b/core/modules/field/tests/src/Unit/Plugin/migrate/process/d7/FieldInstanceSettingsTest.php @@ -28,7 +28,7 @@ public function testTransformImageSettings() { ->disableOriginalConstructor() ->getMock(); - $value = $plugin->transform([[], ['type' => 'image_image'], []], $executable, $row, 'foo'); + $value = $plugin->transform([[], ['type' => 'image_image'], ['data' => '']], $executable, $row, 'foo'); $this->assertInternalType('array', $value['default_image']); $this->assertSame('', $value['default_image']['alt']); $this->assertSame('', $value['default_image']['title']); diff --git a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php index 4e78ee5..bb71418 100644 --- a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php @@ -34,7 +34,7 @@ public function getFieldWidgetMap() { public function processFieldInstance(MigrationInterface $migration) { $process = [ 'plugin' => 'static_map', - 'source' => 'instance_settings/title', + 'source' => 'settings/title', 'bypass' => TRUE, 'map' => [ 'disabled' => DRUPAL_DISABLED, diff --git a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php index 1d18b30..99619bb 100644 --- a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php +++ b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php @@ -43,7 +43,9 @@ public function getFieldFormatterMap() { * {@inheritdoc} */ public function processCckFieldValues(MigrationInterface $migration, $field_name, $field_info) { - if ($field_info['widget_type'] == 'optionwidgets_onoff') { + $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type']; + + if ($widget_type == 'optionwidgets_onoff') { $process = [ 'value' => [ 'plugin' => 'static_map',