5 * Provides migration from other Drupal sites.
8 use Drupal\Core\Database\DatabaseExceptionWrapper;
9 use Drupal\Core\Routing\RouteMatchInterface;
10 use Drupal\migrate\Exception\RequirementsException;
11 use Drupal\migrate\MigrateExecutable;
12 use Drupal\migrate\MigrateMessage;
13 use Drupal\migrate\Plugin\RequirementsInterface;
16 * Implements hook_help().
18 function migrate_drupal_help($route_name, RouteMatchInterface $route_match) {
19 switch ($route_name) {
20 case 'help.page.migrate_drupal':
22 $output .= '<h3>' . t('About') . '</h3>';
23 $output .= '<p>' . t('The Migrate Drupal module provides a framework based on the <a href=":migrate">Migrate module</a> to facilitate migration from a Drupal (6, 7, or 8) site to your website. It does not provide a user interface. For more information, see the <a href=":migrate_drupal">online documentation for the Migrate Drupal module</a>.', [':migrate' => \Drupal::url('help.page', ['name' => 'migrate']), ':migrate_drupal' => 'https://www.drupal.org/documentation/modules/migrate_drupal']) . '</p>';
29 * Implements hook_migration_plugins_alter().
31 function migrate_drupal_migration_plugins_alter(&$definitions) {
32 // This is why the deriver can't do this: the 'd6_taxonomy_vocabulary'
33 // definition is not available to the deriver as it is running inside
35 if (isset($definitions['d6_taxonomy_vocabulary'])) {
36 $vocabulary_migration_definition = [
39 'plugin' => 'd6_taxonomy_vocabulary',
45 $vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($vocabulary_migration_definition);
48 $source_plugin = $vocabulary_migration->getSourcePlugin();
49 if ($source_plugin instanceof RequirementsInterface) {
50 $source_plugin->checkRequirements();
52 $executable = new MigrateExecutable($vocabulary_migration, new MigrateMessage());
53 $process = ['vid' => $definitions['d6_taxonomy_vocabulary']['process']['vid']];
54 foreach ($source_plugin as $row) {
55 $executable->processRow($row, $process);
56 $source_vid = $row->getSourceProperty('vid');
57 $plugin_ids = ['d6_term_node:' . $source_vid, 'd6_term_node_revision:' . $source_vid];
58 foreach ($plugin_ids as $plugin_id) {
59 if (isset($definitions[$plugin_id])) {
60 $definitions[$plugin_id]['process'][$row->getDestinationProperty('vid')] = 'tid';
65 catch (RequirementsException $e) {
66 // This code currently runs whenever the definitions are being loaded and
67 // if you have a Drupal 7 source site then the requirements will not be
68 // met for the d6_taxonomy_vocabulary migration.
70 catch (DatabaseExceptionWrapper $e) {
71 // When the definitions are loaded it is possible the tables will not