diff --git a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml index c47d2c3..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 @@ -35,6 +35,7 @@ process: process: target_id: '0' target_revision_id: '1' + field_summary: body/0/summary field_image: - plugin: iterator @@ -56,7 +57,24 @@ process: revision_uid: revision_uid revision_log: log revision_timestamp: timestamp + field_authors/target_id: + 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 - 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 new file mode 100644 index 0000000..d43f306 --- /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_lookup + 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 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); + } + +}