From 176e291c241469677315b52a76e4583851aced92 Mon Sep 17 00:00:00 2001 From: David Valdez Date: Sun, 28 Oct 2018 21:21:07 -0600 Subject: [PATCH 1/4] Migrate the field_summary --- web/modules/custom/agaric_migration/migrations/agaric_blog.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml index c47d2c3..74524da 100644 --- a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml +++ b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml @@ -35,6 +35,7 @@ process: process: target_id: '0' target_revision_id: '1' + field_summary: body/0/summary field_image: - plugin: iterator From 5edb1365860dd78e6e8e95c3905b0b4abd002d2b Mon Sep 17 00:00:00 2001 From: David Valdez Date: Mon, 29 Oct 2018 12:42:12 -0600 Subject: [PATCH 2/4] Agaric people migration --- .../migrations/agaric_people.yml | 43 +++++++++++++++++++ .../migrations/agaric_people_paragraph.yml | 25 +++++++++++ 2 files changed, 68 insertions(+) create mode 100644 web/modules/custom/agaric_migration/migrations/agaric_people.yml create mode 100644 web/modules/custom/agaric_migration/migrations/agaric_people_paragraph.yml diff --git a/web/modules/custom/agaric_migration/migrations/agaric_people.yml b/web/modules/custom/agaric_migration/migrations/agaric_people.yml new file mode 100644 index 0000000..16d383a --- /dev/null +++ b/web/modules/custom/agaric_migration/migrations/agaric_people.yml @@ -0,0 +1,43 @@ +id: agaric_people +migration_group: agaric +label: Agaric People +source: + plugin: d7_user + constants: + admin_uid: 1 +destination: + plugin: entity:node +process: + type: + plugin: default_value + default_value: people + title: name + created: created + status: status + #This field is empty. + #field_summary: field_bio/0/summary + paragraph_bio: + plugin: migration + migration: agaric_people_paragraph + source: uid + field_body_paragraph: + plugin: iterator + source: + - '@paragraph_bio' + process: + target_id: '0' + target_revision_id: '1' + # By default the admin will create the people nodes. + uid: 'constants/admin_uid' + field_image: + - + plugin: default_value + source: picture + default_value: null + - + plugin: migration_lookup + migration: agaric_file +migration_dependencies: + optional: + - agaric_file + diff --git a/web/modules/custom/agaric_migration/migrations/agaric_people_paragraph.yml b/web/modules/custom/agaric_migration/migrations/agaric_people_paragraph.yml new file mode 100644 index 0000000..abe508f --- /dev/null +++ b/web/modules/custom/agaric_migration/migrations/agaric_people_paragraph.yml @@ -0,0 +1,25 @@ +id: agaric_people_paragraph +migration_group: agaric +label: People Bio paragraph +source: + plugin: d7_user + constants: + admin_uid: 1 + text_format: 'full_html' +process: + uid: 'constants/admin_uid' + status: status + created: created + parent_type: "node" + field_text/value: field_bio/0/value + field_text/format: 'constants/text_format' +destination: + plugin: 'entity_reference_revisions:paragraph' + default_bundle: text +dependencies: + enforced: + module: + - paragraphs +migration_dependencies: + required: + - agaric_user From 77c6286dbb10b5dd3242e793c0e93acac1f0e555 Mon Sep 17 00:00:00 2001 From: David Valdez Date: Mon, 29 Oct 2018 14:02:01 -0600 Subject: [PATCH 3/4] The field_authors is filled with the people nodes. If the node was created by Ben then the field_authors field will have the Ben people node. --- .../custom/agaric_migration/migrations/agaric_blog.yml | 5 +++++ .../custom/agaric_migration/migrations/agaric_people.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml index 74524da..41f5bf4 100644 --- a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml +++ b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml @@ -57,7 +57,12 @@ process: revision_uid: revision_uid revision_log: log revision_timestamp: timestamp + field_authors/target_id: + plugin: migration_lookup + source: node_uid + migration: agaric_people migration_dependencies: required: + - agaric_people - agaric_user - agaric_blog_paragraph diff --git a/web/modules/custom/agaric_migration/migrations/agaric_people.yml b/web/modules/custom/agaric_migration/migrations/agaric_people.yml index 16d383a..d43f306 100644 --- a/web/modules/custom/agaric_migration/migrations/agaric_people.yml +++ b/web/modules/custom/agaric_migration/migrations/agaric_people.yml @@ -17,7 +17,7 @@ process: #This field is empty. #field_summary: field_bio/0/summary paragraph_bio: - plugin: migration + plugin: migration_lookup migration: agaric_people_paragraph source: uid field_body_paragraph: From 1794c6270915fad388a1ea53c4f6ea4f039fa67c Mon Sep 17 00:00:00 2001 From: David Valdez Date: Tue, 30 Oct 2018 12:33:04 -0600 Subject: [PATCH 4/4] Include the tags field migration. --- .../migrations/agaric_blog.yml | 14 ++++++- .../src/Plugin/migrate/source/AgaricNode.php | 40 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php diff --git a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml index 41f5bf4..4014e7e 100644 --- a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml +++ b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml @@ -2,7 +2,7 @@ id: agaric_blog migration_group: agaric label: Agaric Blog source: - plugin: d7_node + plugin: agaric_node node_type: blog destination: plugin: entity:node @@ -61,6 +61,18 @@ process: plugin: migration_lookup source: node_uid migration: agaric_people + field_tags: + plugin: sub_process + source: field_tags_names + process: + target_id: + - plugin: entity_generate + source: name + value_key: name + bundle_key: vid + bundle: tags + entity_type: taxonomy_term + ignore_case: true migration_dependencies: required: - agaric_people diff --git a/web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php b/web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php new file mode 100644 index 0000000..5c285ae --- /dev/null +++ b/web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php @@ -0,0 +1,40 @@ +getSourceProperty('nid'); + // Get the taxonomy tags names. + $tags = $this->getFieldValues('node', 'field_tags', $nid); + $names = []; + foreach ($tags as $tag) { + $tid = $tag['tid']; + + $query = $this->select('taxonomy_term_data', 't'); + $query->condition('tid', $tid); + $query->addField('t', 'name'); + $result = $query->execute()->fetchAssoc(); + $names[] = ['name' => $result['name']]; + } + $row->setSourceProperty('field_tags_names', $names); + + return parent::prepareRow($row); + } + +}