-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmotionsplan_exercise_program.migrate.inc
50 lines (39 loc) · 1.45 KB
/
motionsplan_exercise_program.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
<?php
/**
* @file
* Migrations for motionsplan_exercise.
*/
class MotionsplanProgramNode extends Migration {
public function __construct(array $arguments = array()) {
parent::__construct($arguments);
$this->description = t('Import exercise program nodes.');
$this->dependencies = array('MotionsplanExerciseNode');
// Create a map object for tracking the relationships between source rows
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
),
MigrateDestinationNode::getKeySchema()
);
// Create a MigrateSource object.
$this->source = new MigrateSourceCSV(drupal_get_path('module', 'motionsplan_exercise_program') . '/import/programs.csv', $this->csvcolumns(), array('header_rows' => 1));
$this->destination = new MigrateDestinationNode('trainingprogram');
$this->addFieldMapping('uid', 'uid')->defaultValue(1);
$this->addFieldMapping('title', 'title');
$this->addFieldMapping('body', 'description');
$this->addFieldMapping('body:format')
->defaultValue('plain_text');
$this->addFieldMapping('field_program_exercises', 'exercises')
->sourceMigration('MotionsplanExerciseNode');
}
function csvcolumns() {
$columns[0] = array('id', 'id');
$columns[1] = array('title', 'title');
$columns[2] = array('exercises');
return $columns;
}
}