|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Migrations for Series Nodes. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
class DFSMEDSeriesNodes extends DemoFrameworkBaseNodesUUID { |
|
9
|
|
|
public function __construct($arguments) { |
|
10
|
|
|
parent::__construct($arguments); |
|
11
|
|
|
$this->description = t('Import nodes.'); |
|
12
|
|
|
$this->map = new MigrateSQLMap($this->machineName, |
|
13
|
|
|
array( |
|
14
|
|
|
'uuid' => array( |
|
15
|
|
|
'type' => 'char', |
|
16
|
|
|
'length' => 36, |
|
17
|
|
|
'not null' => FALSE, |
|
18
|
|
|
), |
|
19
|
|
|
), |
|
20
|
|
|
MigrateDestinationNode::getKeySchema() |
|
21
|
|
|
); |
|
22
|
|
|
$import_path = drupal_get_path('module', 'dfs_med') . '/import/'; |
|
23
|
|
|
// Create a MigrateSource object. |
|
24
|
|
|
$this->source = new MigrateSourceCSV($import_path . 'dfs_med.nodes.series.csv', $this->csvcolumns(), array('header_rows' => 1)); |
|
25
|
|
|
$this->destination = new MigrateDestinationNode('series'); |
|
26
|
|
|
// Created |
|
27
|
|
|
$this->addFieldMapping('created', 'created')->defaultValue(strtotime("now")); |
|
28
|
|
|
// Brand |
|
29
|
|
|
$this->addFieldMapping('field_brand', 'brand')->sourceMigration('DFSMEDBrandNodes'); |
|
30
|
|
|
// Associated Product |
|
31
|
|
|
$this->addFieldMapping('field_commerce_product', 'commerce')->sourceMigration('DFSMEDCommerceNodes'); |
|
32
|
|
|
// Year |
|
33
|
|
|
$this->addfieldmapping('field_year', 'year'); |
|
34
|
|
|
// Splash Image |
|
35
|
|
|
$this->addFieldMapping('field_splash_image', 'splash'); |
|
36
|
|
|
$this->addFieldMapping('field_splash_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE); |
|
37
|
|
|
$this->addFieldMapping('field_splash_image:source_dir')->defaultValue($import_path . 'images'); |
|
38
|
|
|
$this->addFieldMapping('field_splash_image:destination_file', 'filename'); |
|
39
|
|
|
// Series Episodes |
|
40
|
|
|
$this->addFieldMapping('field_series_episodes', 'episodes')->separator(',')->sourceMigration('DFSMEDEpisodeNodes'); |
|
41
|
|
|
// Persona |
|
42
|
|
|
$this->addFieldMapping('field_persona', 'persona'); |
|
43
|
|
|
// Site Section |
|
44
|
|
|
$this->addFieldMapping('field_site_section', 'site_section')->defaultValue("Content"); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
function csvcolumns() { |
|
|
|
|
|
|
48
|
|
|
$columns[0] = array('uuid', 'UUID'); |
|
|
|
|
|
|
49
|
|
|
$columns[1] = array('title', 'Title'); |
|
50
|
|
|
$columns[2] = array('brand', 'Brand'); |
|
51
|
|
|
$columns[3] = array('commerce', 'Commerce'); |
|
52
|
|
|
$columns[4] = array('year', 'Year'); |
|
53
|
|
|
$columns[5] = array('splash', 'Splash'); |
|
54
|
|
|
$columns[6] = array('body', 'Body'); |
|
55
|
|
|
$columns[7] = array('episodes', 'Episodes'); |
|
56
|
|
|
$columns[8] = array('persona', 'Persona'); |
|
57
|
|
|
return $columns; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.