Add the summary in the authors.

The summary is just the bio of the author.
This commit is contained in:
David Valdez 2019-10-02 13:44:29 -05:00
parent 0bdcbeb87f
commit 9108d898df
2 changed files with 25 additions and 0 deletions

View file

@ -28,6 +28,7 @@ process:
- plugin: migration_lookup - plugin: migration_lookup
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
destination: destination:
plugin: 'entity:node' plugin: 'entity:node'
default_bundle: people default_bundle: people

View file

@ -24,6 +24,30 @@ class Author extends SqlBase {
// Make sure to all the author names are trimmed. // Make sure to all the author names are trimmed.
$row->setSourceProperty('field_author_value', trim($field_author)); $row->setSourceProperty('field_author_value', trim($field_author));
// The bio value is going to be get from the last contribution of the user
// where the bio field is not empty.
$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',
['field_author' => $field_author]
);
foreach ($query as $record) {
$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",
['entity_id' => $record->entity_id, 'revision_id' => $record->revision_id]
);
$bio_result = $bio_query->fetchAssoc();
// Once we find a bio no need to continue.
if (!empty($bio_result)) {
break;
}
}
$row->setSourceProperty('bio', ["value" => '']);
if (!empty($bio_result)) {
$row->setSourceProperty('bio', ["value" => $bio_result['field_author_bio_value']]);
}
return parent::prepareRow($row); return parent::prepareRow($row);
} }