Add the bio of the persons in the paragraph field

This commit is contained in:
David Valdez 2019-10-02 21:02:54 -05:00
parent 964f541a08
commit e7f8b292c9
3 changed files with 58 additions and 1 deletions

View file

@ -29,6 +29,17 @@ process:
migration: upgrade_d7_taxonomy_term_custom_terms migration: upgrade_d7_taxonomy_term_custom_terms
source: constants/author_type_source_id source: constants/author_type_source_id
field_summary: bio field_summary: bio
paragraph_bio:
plugin: migration
migration: upgrade_d7_node_story_bio_paragraph
source: field_author_value
field_body_paragraph:
- plugin: iterator
source:
- '@paragraph_bio'
process:
target_id: '0'
target_revision_id: '1'
destination: destination:
plugin: 'entity:node' plugin: 'entity:node'
default_bundle: people default_bundle: people

View file

@ -0,0 +1,38 @@
id: upgrade_d7_node_story_bio_paragraph
migration_group: migrate_drupal_7_geo
label: Body paragraph
source:
plugin: geod7_author
constants:
status: 1
format: full_html
process:
nid:
plugin: migration_lookup
source: field_author_value
migration: upgrade_d7_node_story_author
uid:
- plugin: get
source: uid
status: constants/status
parent_type: "node"
field_text: bio
field_text/format: constants/format
# -
# plugin: sub_process
# source: bio
# process:
# value: value
# format:
# plugin: default_value
# default_value: 'full_html'
destination:
plugin: 'entity_reference_revisions:paragraph'
default_bundle: text
dependencies:
enforced:
module:
- paragraphs
migration_dependencies:
required:
- upgrade_d7_user

View file

@ -27,10 +27,18 @@ class Author extends SqlBase {
// The bio value is going to be get from the last contribution of the user // The bio value is going to be get from the last contribution of the user
// where the bio field is not empty. // where the bio field is not empty.
$query = $this->database->query( $query = $this->database->query(
'SELECT entity_id, revision_id FROM field_data_field_author WHERE field_author_value = :field_author ORDER BY entity_id DESC', 'SELECT
fdfa.entity_id,
fdfa.revision_id,
n.nid
FROM field_data_field_author fdfa
LEFT JOIN node n ON (n.nid = fdfa.entity_id)
WHERE field_author_value = :field_author
ORDER BY entity_id DESC',
['field_author' => $field_author] ['field_author' => $field_author]
); );
foreach ($query as $record) { foreach ($query as $record) {
$row->setSourceProperty('uid', $record->uid);
$bio_query = $this->database->query( $bio_query = $this->database->query(
"SELECT field_author_bio_value FROM field_data_field_author_bio WHERE entity_id = :entity_id AND revision_id = :revision_id", "SELECT field_author_bio_value FROM field_data_field_author_bio WHERE entity_id = :entity_id AND revision_id = :revision_id",
['entity_id' => $record->entity_id, 'revision_id' => $record->revision_id] ['entity_id' => $record->entity_id, 'revision_id' => $record->revision_id]