diff --git a/migration_templates/d7_paragraph_field.yml b/migration_templates/d7_paragraph_field.yml new file mode 100644 index 0000000..9591d47 --- /dev/null +++ b/migration_templates/d7_paragraph_field.yml @@ -0,0 +1,53 @@ +id: d7_paragraph_field +label: Paragraph field configuration +migration_tags: + - Drupal 7 +source: + plugin: d7_paragraph_field + constants: + status: true + langcode: und +process: + entity_type: + plugin: static_map + source: entity_type + bypass: true + map: + paragraphs_item: paragraph + status: 'constants/status' + langcode: 'constants/langcode' + field_name: field_name + type: + plugin: static_map + source: type + map: + date: datetime + datestamp: datetime + datetime: datetime + email: email + file: file + image: image + link_field: link + list_boolean: boolean + list_integer: list_integer + list_text: list_string + number_integer: integer + number_decimal: decimal + number_float: float + paragraphs: entity_reference_revisions + paragraphs_item: paragraph + phone: telephone + taxonomy_term_reference: entity_reference + text: text + text_long: text_long + text_with_summary: text_with_summary + translatable: translatable + cardinality: cardinality + settings: + plugin: d7_paragraph_field_settings +destination: + plugin: entity:field_storage_config +migration_dependencies: + required: + - d7_paragraph_type + - d7_field diff --git a/migration_templates/d7_paragraph_field_instance.yml b/migration_templates/d7_paragraph_field_instance.yml new file mode 100644 index 0000000..958cea8 --- /dev/null +++ b/migration_templates/d7_paragraph_field_instance.yml @@ -0,0 +1,37 @@ +id: d7_paragraph_field_instance +label: Paragraph field instance configuration +migration_tags: + - Drupal 7 +source: + plugin: d7_paragraph_field_instance + constants: + status: true +process: + entity_type: + plugin: static_map + source: entity_type + bypass: true + map: + paragraphs_item: paragraph + field_name: field_name + bundle: bundle + label: label + description: description + required: required + status: 'constants/status' + settings: + plugin: d7_paragraph_field_instance_settings + source: + - instance_settings + - widget_settings + default_value_function: '' + default_value: + plugin: d7_field_instance_defaults + source: + - default_value + - widget_settings +destination: + plugin: entity:field_config +migration_dependencies: + required: + - d7_paragraph_field diff --git a/migration_templates/d7_paragraph_type.yml b/migration_templates/d7_paragraph_type.yml new file mode 100644 index 0000000..8c94520 --- /dev/null +++ b/migration_templates/d7_paragraph_type.yml @@ -0,0 +1,11 @@ +id: d7_paragraph_type +label: Paragraph type configuration +migration_tags: + - Drupal 7 +source: + plugin: d7_paragraph_type +process: + id: bundle + label: name +destination: + plugin: entity:paragraphs_type diff --git a/src/Plugin/migrate/destination/EntityParagraphType.php b/src/Plugin/migrate/destination/EntityParagraphType.php new file mode 100644 index 0000000..a5c7283 --- /dev/null +++ b/src/Plugin/migrate/destination/EntityParagraphType.php @@ -0,0 +1,20 @@ +getBundleInfo('paragraph')); + $weight = count($paragraph_bundle_ids) + 1; + + if (isset($paragraph_bundle_ids) && count($paragraph_bundle_ids) > 0) { + foreach ($paragraph_bundle_ids as $paragraph_bundle_id) { + $settings['handler_settings']['target_bundles'][$paragraph_bundle_id] = $paragraph_bundle_id; + $enabled = FALSE; + if (isset($settings['allowed_bundles'][$paragraph_bundle_id])) { + $enabled = $settings['allowed_bundles'][$paragraph_bundle_id] === $paragraph_bundle_id; + } + $settings['handler_settings']['target_bundles_drag_drop'][$paragraph_bundle_id] = array( + 'weight' => $weight, + 'enabled' => $enabled + ); + + $weight++; + } + } + } + else { + $settings = parent::transform($value, $migrate_executable, $row, $destination_property); + } + + return $settings; + } + +} diff --git a/src/Plugin/migrate/process/ParagraphFieldSettings.php b/src/Plugin/migrate/process/ParagraphFieldSettings.php new file mode 100644 index 0000000..388c4ff --- /dev/null +++ b/src/Plugin/migrate/process/ParagraphFieldSettings.php @@ -0,0 +1,37 @@ +getSourceProperty('settings'); + + if ('paragraphs' == $row->getSourceProperty('type')) { + $value['target_type'] = 'paragraph'; + } + else { + $value = parent::transform($value, $migrate_executable, $row, $destination_property); + } + + return $value; + } + +} diff --git a/src/Plugin/migrate/source/ParagraphField.php b/src/Plugin/migrate/source/ParagraphField.php new file mode 100644 index 0000000..4a09a6f --- /dev/null +++ b/src/Plugin/migrate/source/ParagraphField.php @@ -0,0 +1,34 @@ +orConditionGroup() + ->condition('fc.type', 'paragraphs') + ->condition('fci.entity_type', 'paragraphs_item'); + $query->condition($group); + return $query; + } + +} diff --git a/src/Plugin/migrate/source/ParagraphFieldInstance.php b/src/Plugin/migrate/source/ParagraphFieldInstance.php new file mode 100644 index 0000000..989f9ee --- /dev/null +++ b/src/Plugin/migrate/source/ParagraphFieldInstance.php @@ -0,0 +1,34 @@ +orConditionGroup() + ->condition('fc.type', 'paragraphs') + ->condition('fci.entity_type', 'paragraphs_item'); + $query->condition($group); + return $query; + } + +} diff --git a/src/Plugin/migrate/source/ParagraphType.php b/src/Plugin/migrate/source/ParagraphType.php new file mode 100644 index 0000000..66ec24a --- /dev/null +++ b/src/Plugin/migrate/source/ParagraphType.php @@ -0,0 +1,48 @@ +select('paragraphs_bundle', 't')->fields('t'); + } + + /** + * {@inheritdoc} + */ + public function fields() { + return array( + 'bundle' => $this->t('Machine name of the paragraph type.'), + 'name' => $this->t('Human name of the paragraph type.'), + 'locked' => $this->t('Flag.'), + ); + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['bundle']['type'] = 'string'; + return $ids; + } + +}