-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdhs_migrate.migrate.inc
122 lines (110 loc) · 4.08 KB
/
dhs_migrate.migrate.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/**
* Implements hook_migrate_api().
*/
function dhs_migrate_migrate_api() {
$api = array(
'api' => 2,
'groups' => array(
'content_migration' => array(
'title' => t('DHS Drupal 6 to Drupal 7 migrations.'),
),
),
);
// Specify the DB connection and the source Drupal version.
$common_arguments = array(
'source_connection' => 'legacy',
'source_version' => 6,
'group_name' => 'content_migration',
'format_mappings' => array(
'1' => 'filtered_html',
'2' => 'full_html',
'3' => 'editor',
),
);
// Register the user migration.
// We just use the migrate_d2d D6 migration class as-is.
$api['migrations']['User'] = $common_arguments + array(
'description' => t('Migration of users from Drupal 6'),
'class_name' => 'DrupalUser6Migration',
);
// Register the file migration.
$api['migrations']['File'] = $common_arguments + array(
'machine_name' => 'filemigration',
'description' => t('Import Drupal 6 files'),
'class_name' => 'DrupalFile6Migration',
'user_migration' => 'User',
'default_uid' => 4,
'source_dir' => DRUPAL_ROOT . '/../d6_files',
'destination_dir' => 'public://legacy_files',
);
// For vocabulary migrations, source_vocabulary and destination_vocabulary are
// required arguments. Note that in Drupal 6 vocabularies did not have machine
// names, so we use the vocabulary ID to uniquely identify them.
$vocabulary_arguments = array(
'ImageTags' => array(
'description' => t('Migration of photo terms from Drupal 6'),
'source_vocabulary' => '5', // D6 Vocabulary ID
'destination_vocabulary' => 'bilde',
),
'Topics' => array(
'description' => t('Migration of Topics terms from Drupal 6'),
'source_vocabulary' => '1', // D6 Vocabulary ID
'destination_vocabulary' => 'tags',
'class_name' => 'DHSTerm6Migration',
),
'Category' => array(
'description' => t('Migration of Catecgory terms from Drupal 6'),
'source_vocabulary' => '4', // D6 Vocabulary ID
'destination_vocabulary' => 'tags',
'class_name' => 'DHSTerm6Migration',
),
);
// Again, we're using the migrate_d2d class directly.
// The soft dependency says that while we don't have to run the user migration
// first, we want to make sure it's listed first so the vocabularies are
// listed right ahead of the node migrations.
$common_vocabulary_arguments = $common_arguments + array(
'class_name' => 'DrupalTerm6Migration',
'soft_dependencies' => array('User'),
);
foreach ($vocabulary_arguments as $migration_name => $arguments) {
$arguments += $common_vocabulary_arguments;
$api['migrations'][$migration_name] = $arguments;
}
// Node migrations - each has its own class derived from the migrate_d2d class,
// specifying its particular field mappings and transformations. source_type
// and destination_type are required arguments.
$node_arguments = array(
'Album' => array(
'class_name' => 'AlbumMigration',
'description' => t('Migration of photo album nodes from Drupal 6'),
'source_type' => 'fotoalbum',
'destination_type' => 'fotoalbum',
),
'Image' => array(
'class_name' => 'ImageMigration',
'description' => t('Migration of bilde nodes from Drupal 6'),
'source_type' => 'bilde',
'destination_type' => 'bilde',
'dependencies' => array('ImageTags', 'Album'),
),
'Article' => array(
'class_name' => 'ArticleMigration',
'description' => t('Migration of article nodes from Drupal 6'),
'source_type' => 'page',
'destination_type' => 'innhold',
'dependencies' => array(),
),
);
// Tell the node migrations where the users are coming from, so they can
// set up the dependency and resolve D6->D7 uids.
$common_node_arguments = $common_arguments + array(
'user_migration' => 'User'
);
foreach ($node_arguments as $migration_name => $arguments) {
$arguments = array_merge_recursive($arguments, $common_node_arguments);
$api['migrations'][$migration_name] = $arguments;
}
return $api;
}