Merge branch 'migration-fixes' into 'master'
Migration extras See merge request agaric/sites/agaric-com!28
This commit is contained in:
commit
81905ed283
4 changed files with 127 additions and 1 deletions
|
@ -2,7 +2,7 @@ id: agaric_blog
|
||||||
migration_group: agaric
|
migration_group: agaric
|
||||||
label: Agaric Blog
|
label: Agaric Blog
|
||||||
source:
|
source:
|
||||||
plugin: d7_node
|
plugin: agaric_node
|
||||||
node_type: blog
|
node_type: blog
|
||||||
destination:
|
destination:
|
||||||
plugin: entity:node
|
plugin: entity:node
|
||||||
|
@ -35,6 +35,7 @@ process:
|
||||||
process:
|
process:
|
||||||
target_id: '0'
|
target_id: '0'
|
||||||
target_revision_id: '1'
|
target_revision_id: '1'
|
||||||
|
field_summary: body/0/summary
|
||||||
field_image:
|
field_image:
|
||||||
-
|
-
|
||||||
plugin: iterator
|
plugin: iterator
|
||||||
|
@ -56,7 +57,24 @@ process:
|
||||||
revision_uid: revision_uid
|
revision_uid: revision_uid
|
||||||
revision_log: log
|
revision_log: log
|
||||||
revision_timestamp: timestamp
|
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:
|
migration_dependencies:
|
||||||
required:
|
required:
|
||||||
|
- agaric_people
|
||||||
- agaric_user
|
- agaric_user
|
||||||
- agaric_blog_paragraph
|
- agaric_blog_paragraph
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\agaric_migration\Plugin\migrate\source;
|
||||||
|
|
||||||
|
use Drupal\migrate\Row;
|
||||||
|
use Drupal\node\Plugin\migrate\source\d7\Node;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the Taxonomy term name in the query.
|
||||||
|
*
|
||||||
|
* This adds the sourceProperty field_tags_names which are the name of the terms
|
||||||
|
*
|
||||||
|
* @MigrateSource(
|
||||||
|
* id = "agaric_node",
|
||||||
|
* source_module = "node"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class AgaricNode extends Node {
|
||||||
|
|
||||||
|
public function prepareRow(Row $row) {
|
||||||
|
$nid = $row->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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue