public function DrupalMigrationGenerator::createMigrations in Drupal-to-Drupal data migration 8.3
Creates a set of WordPress import migrations based on configuration settings.
File
- src/
DrupalMigrationGenerator.php, line 75
Class
- DrupalMigrationGenerator
- Functionality to construct Drupal migrations from broad configuration settings.
Namespace
Drupal\migrate_d2dCode
public function createMigrations() {
// Create the migration group.
$group_configuration = [
'id' => $this->configuration['group_id'],
// @todo: Add Drupal site title in here.
'label' => 'Imports from Drupal site',
'source_type' => 'Drupal ' . $this->configuration['version'],
'shared_configuration' => [
'source' => [
'key' => 'drupal_import',
'database' => [
$this->configuration['database'],
],
],
],
];
MigrationGroup::create($group_configuration)
->save();
// Determine the uid mappings, creating an author migration if needed.
if ($this->configuration['user_migration']) {
// @todo: Implement role migration.
$this->userID = $this->configuration['prefix'] . 'd6_user';
$migration = static::createEntityFromPlugin('d6_user', $this->userID);
$migration
->set('migration_group', $this->configuration['group_id']);
$migration
->save();
$this->uidMapping = [
'plugin' => 'migration',
'migration' => $this->userID,
'source' => 'uid',
];
}
return;
// Set up the attachment migration.
/* @todo: Wait until https://www.drupal.org/node/2695297 to complete implementation.
$attachment_id = $this->configuration['prefix'] . 'wordpress_attachments';
$migration = static::createEntityFromPlugin('wordpress_attachments', $attachment_id);
$migration->set('migration_group', $this->configuration['group_id']);
$process = $migration->get('process');
$process['uid'] = $this->uidMapping;
$migration->set('process', $process);
if (!empty($this->authorID)) {
$migration->set('migration_dependencies', ['required' => [$this->authorID]]);
}
$migration->save();
*/
// Setup vocabulary migrations if requested.
if ($this->configuration['tag_vocabulary']) {
$this->tagsID = $this->configuration['prefix'] . 'wordpress_tags';
$migration = static::createEntityFromPlugin('wordpress_tags', $this->tagsID);
$migration
->set('migration_group', $this->configuration['group_id']);
$process = $migration
->get('process');
$process['vid'] = [
'plugin' => 'default_value',
'default_value' => $this->configuration['tag_vocabulary'],
];
$migration
->set('process', $process);
$migration
->save();
}
if ($this->configuration['category_vocabulary']) {
$this->categoriesID = $this->configuration['prefix'] . 'wordpress_categories';
$migration = static::createEntityFromPlugin('wordpress_categories', $this->categoriesID);
$migration
->set('migration_group', $this->configuration['group_id']);
$process = $migration
->get('process');
$process['vid'] = [
'plugin' => 'default_value',
'default_value' => $this->configuration['category_vocabulary'],
];
$migration
->set('process', $process);
$migration
->save();
}
// Setup the content migrations.
foreach ([
'post',
'page',
] as $wordpress_type) {
if (!empty($this->configuration[$wordpress_type]['type'])) {
$this
->createContentMigration($wordpress_type);
}
}
}