-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartesis_migration.module
More file actions
136 lines (125 loc) · 4.78 KB
/
artesis_migration.module
File metadata and controls
136 lines (125 loc) · 4.78 KB
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
<?php
/**
* @file
*/
/**
* IMPORTANT: File source and DB name (as written in settings.php) are HARDCODED
* for the sake of simplicity. When migrating one has to:
* 1. set legacy DB name (connection name as defined in settings.php $database definition) to AM_SOURCE_DB.
* 2. create a symlink to legacy files called DRUPAL_ROOT . '/' . AM_FILES
*/
define('AM_SOURCE_DB', 'easyprofile');
define('AM_FILES', 'easyprofile_files');
/**
* Implements hook_migrate_api().
*/
function artesis_migration_migrate_api() {
return array('api' => 2);
}
/**
* Implementation of hook_flush_caches().
*/
function artesis_migration_flush_caches() {
artesis_migration_register_migrations();
}
/**
* Register all of the migrations.
*/
function artesis_migration_register_migrations() {
$common_arguments = array(
'source_connection' => AM_SOURCE_DB,
'source_version' => 7,
);
// The description and the migration machine name are also required arguments,
// which will be unique for each migration you register.
$arguments = $common_arguments + array(
'description' => t('Migration of users'),
'machine_name' => 'User',
);
// We just use the migrate_d2d D7 migration class as-is.
Migration::registerMigration('DrupalUser7Migration', $arguments['machine_name'],
$arguments);
// 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(
'soft_dependencies' => array('User'),
);
$vocabulary_arguments = array(
'description' => t('Migration of Category terms'),
'machine_name' => 'Category',
'source_vocabulary' => 'category',
'destination_vocabulary' => 'category',
);
$arguments = $common_vocabulary_arguments + $vocabulary_arguments;
Migration::registerMigration('DrupalTerm7Migration', $arguments['machine_name'],
$arguments);
$vocabulary_arguments = array(
'description' => t('Migration of Tags terms'),
'machine_name' => 'Tags',
'source_vocabulary' => 'ding_content_tags',
'destination_vocabulary' => 'ding_content_tags',
);
$arguments = $common_vocabulary_arguments + $vocabulary_arguments;
Migration::registerMigration('DrupalTerm7Migration', $arguments['machine_name'],
$arguments);
// File migration
$arguments = $common_arguments + array(
'class_name' => 'DrupalFile7Migration',
'machine_name' => 'Files',
'description' => t('Migration of files'),
// @todo: file path may vary, need to clarify that before final deployment.
'source_dir' => DRUPAL_ROOT . '/' . AM_FILES,
'user_migration' => 'User',
'default_uid' => 1,
);
Migration::registerMigration($arguments['class_name'], $arguments['machine_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(
array(
'class_name' => 'BaseNodeMigration',
'description' => t('Migration of page nodes'),
'machine_name' => 'Page',
'source_type' => 'ding_page',
'destination_type' => 'ding_page',
'dependencies' => array('Tags', 'Category', 'Files'),
),
array(
'class_name' => 'BaseNodeMigration',
'description' => t('Migration of news nodes'),
'machine_name' => 'News',
'source_type' => 'ding_news',
'destination_type' => 'ding_news',
'dependencies' => array('Tags', 'Category', 'Files'),
),
array(
'class_name' => 'EventMigration',
'description' => t('Migration of event nodes'),
'machine_name' => 'Event',
'source_type' => 'ding_event',
'destination_type' => 'ding_event',
'dependencies' => array('Tags', 'Category', 'Files'),
),
array(
'class_name' => 'CampaignMigration',
'description' => t('Migration of campaigns'),
'machine_name' => 'Campaign',
'source_type' => 'ding_campaign',
'destination_type' => 'ding_campaign',
'dependencies' => array('Tags', 'Category', 'Files', 'Page', 'News', 'Event'),
),
);
// Tell the node migrations where the users are coming from, so they can
// set up the dependency and resolve D7->D7 uids.
$common_node_arguments = $common_arguments + array(
'user_migration' => 'User',
);
foreach ($node_arguments as $arguments) {
$arguments = array_merge_recursive($arguments, $common_node_arguments);
Migration::registerMigration($arguments['class_name'], $arguments['machine_name'],
$arguments);
}
}