-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrip_migrate.module
225 lines (199 loc) · 7.08 KB
/
trip_migrate.module
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
/**
* Implementation of hook_flush_caches().
*/
function trip_migrate_flush_caches() {
trip_migrate_register_migrations();
}
/**
* Register all D6->D7 migrations.
*/
function trip_migrate_register_migrations() {
$common_arguments = array(
'source_connection' => 'trip',
'source_version' => 6,
);
// Users
$arguments = $common_arguments + array(
'description' => t('Migration of users from Drupal 6'),
'machine_name' => 'TripUser',
);
Migration::registerMigration('TripUserMigration', $arguments['machine_name'],
$arguments);
// Vocabularies
$vocabulary_arguments = array(
array(
'description' => t('Migration of Destination terms from Drupal 6'),
'machine_name' => 'TripTermDestination',
'source_vocabulary' => '6',
'destination_vocabulary' => 'destination',
),
array(
'description' => t('Migration of Topic terms from Drupal 6'),
'machine_name' => 'TripTermTopic',
'source_vocabulary' => '9',
'destination_vocabulary' => 'topic',
),
array(
'description' => t('Migration of Style terms from Drupal 6'),
'machine_name' => 'TripTermStyle',
'source_vocabulary' => '5',
'destination_vocabulary' => 'style',
),
);
$common_vocabulary_arguments = $common_arguments + array(
'class_name' => 'DrupalTerm6Migration',
'soft_dependencies' => array('TripUser'),
);
foreach ($vocabulary_arguments as $arguments) {
$arguments += $common_vocabulary_arguments;
Migration::registerMigration($arguments['class_name'], $arguments['machine_name'], $arguments);
}
// Nodes
$node_arguments = array(
array(
'description' => t('Migration of trip_forum nodes from Drupal 6'),
'machine_name' => 'TripNodeForum',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_forum',
'destination_type' => 'forum',
),
array(
'description' => t('Migration of trip_forum_other nodes from Drupal 6'),
'machine_name' => 'TripNodeForumOther',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_forum_other',
'destination_type' => 'forum_other',
),
array(
'description' => t('Migration of trip_forum_expat nodes from Drupal 6'),
'machine_name' => 'TripNodeForumExpat',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_forum_expat',
'destination_type' => 'forum_expat',
),
array(
'description' => t('Migration of trip_forum_buysell nodes from Drupal 6'),
'machine_name' => 'TripNodeForumBuysell',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_forum_buysell',
'destination_type' => 'forum_buysell',
),
array(
'description' => t('Migration of trip_forum_travelmate nodes from Drupal 6'),
'machine_name' => 'TripNodeForumTravelmate',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_forum_travelmate',
'destination_type' => 'forum_travelmate',
),
array(
'description' => t('Migration of trip_image nodes from Drupal 6'),
'machine_name' => 'TripNodeImage',
'class_name' => 'TripNodeImageMigration',
'source_type' => 'trip_image',
'destination_type' => 'image',
),
array(
'description' => t('Migration of trip_blog nodes from Drupal 6'),
'machine_name' => 'TripNodeBlog',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_blog',
'destination_type' => 'blog',
),
/* array(
'description' => t('Migration of trip_forum_editor nodes from Drupal 6'),
'machine_name' => 'TripNodeForumEditor',
'class_name' => 'TripNodeMigration',
'source_type' => 'trip_forum_editor',
'destination_type' => 'forum_editor',
),
*/
);
$common_node_arguments = $common_arguments + array(
'user_migration' => 'TripUser',
'soft_dependencies' => array('TripTermDestination', 'TripTermTopic', 'TripTermStyle'),
);
foreach ($node_arguments as $arguments) {
$arguments = array_merge_recursive($arguments, $common_node_arguments);
Migration::registerMigration($arguments['class_name'], $arguments['machine_name'],
$arguments);
}
// Comments
$comment_arguments = array(
array(
'description' => t('Migration of trip_forum comments from Drupal 6'),
'machine_name' => 'TripNodeForumComment',
'source_type' => 'trip_forum',
'destination_type' => 'forum',
'node_migration' => 'TripNodeForum',
),
array(
'description' => t('Migration of trip_forum_other comments from Drupal 6'),
'machine_name' => 'TripNodeForumOtherComment',
'source_type' => 'trip_forum_other',
'destination_type' => 'forum_other',
'node_migration' => 'TripNodeForumOther',
),
array(
'description' => t('Migration of trip_forum_expat comments from Drupal 6'),
'machine_name' => 'TripNodeForumExpatComment',
'source_type' => 'trip_forum_expat',
'destination_type' => 'forum_expat',
'node_migration' => 'TripNodeForumExpat',
),
array(
'description' => t('Migration of trip_forum_buysell comments from Drupal 6'),
'machine_name' => 'TripNodeForumBuysellComment',
'source_type' => 'trip_forum_buysell',
'destination_type' => 'forum_buysell',
'node_migration' => 'TripNodeForumBuysell',
),
array(
'description' => t('Migration of trip_forum_travelmate comments from Drupal 6'),
'machine_name' => 'TripNodeForumTravelmateComment',
'source_type' => 'trip_forum_travelmate',
'destination_type' => 'forum_travelmate',
'node_migration' => 'TripNodeForumTravelmate',
),
array(
'description' => t('Migration of trip_image comments from Drupal 6'),
'machine_name' => 'TripNodeImageComment',
'source_type' => 'trip_image',
'destination_type' => 'image',
'node_migration' => 'TripNodeImage',
),
array(
'description' => t('Migration of trip_blog comments from Drupal 6'),
'machine_name' => 'TripNodeBlogComment',
'source_type' => 'trip_blog',
'destination_type' => 'blog',
'node_migration' => 'TripNodeBlog',
),
/*
array(
'description' => t('Migration of trip_forum_editor comments from Drupal 6'),
'machine_name' => 'TripNodeForumEditorComment',
'source_type' => 'trip_forum_editor',
'destination_type' => 'forum_editor',
'node_migration' => 'TripNodeForumEditor',
),
*/
);
$common_comment_arguments = $common_arguments + array(
'user_migration' => 'TripUser',
'class_name' => 'TripCommentMigration',
);
foreach ($comment_arguments as $arguments) {
$arguments = array_merge_recursive($arguments, $common_comment_arguments);
Migration::registerMigration($arguments['class_name'], $arguments['machine_name'], $arguments);
}
}
/**
* Implementation of hook_migrate_api().
*/
function trip_migrate_migrate_api() {
$api = array(
'api' => 2,
);
return $api;
}