Add the Authors migration
This commit is contained in:
parent
6e68f54700
commit
927a9d0351
2 changed files with 90 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue