Add the Authors migration

This commit is contained in:
David Valdez 2019-08-05 19:56:51 -05:00
parent 6e68f54700
commit 927a9d0351
2 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,27 @@
langcode: en
status: true
dependencies: { }
id: upgrade_d7_node_story_author
class: Drupal\migrate\Plugin\Migration
field_plugin_method: alterFieldInstanceMigration
cck_plugin_method: null
migration_tags:
- 'Drupal 7'
- Content
migration_group: migrate_drupal_7_geo
label: 'Authors (Story authors)'
source:
constants:
user_id: 1
author_status: 1
plugin: geod7_author
process:
title: field_author_value
uid: constants/user_id
status: constants/author_status
destination:
plugin: 'entity:node'
default_bundle: people
migration_dependencies:
required: { }
optional: { }

View file

@ -0,0 +1,63 @@
<?php
namespace Drupal\geo_upgrade\Plugin\migrate\source;
use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;
/**
* Drupal 7 node source from database.
*
* @MigrateSource(
* id = "geod7_author",
* source_module = "geo_upgrade"
* )
*/
class Author extends SqlBase {
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$field_author = $row->getSourceProperty('field_author_value');
// Make sure to all the author names are trimmed.
$row->setSourceProperty('field_author_value', trim($field_author));
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
'field_author_value' => $this->t('Author Name'),
];
return $fields;
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['field_author_value']['type'] = 'string';
$ids['field_author_value']['alias'] = 'fdfa';
return $ids;
}
/**
* {@inheritdoc}
*/
public function query() {
$select = $this->select('field_data_field_author', 'fdfa')
->fields('fdfa', [
'field_author_value',
])
->groupBy('field_author_value');
return $select;
}
}