|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Migrations for Brand Nodes. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
class DFSMEDBrandNodes extends DemoFrameworkBaseNodesUUID { |
|
9
|
|
|
|
|
10
|
|
|
public function __construct($arguments) { |
|
11
|
|
|
parent::__construct($arguments); |
|
12
|
|
|
$this->description = t('Import nodes.'); |
|
13
|
|
|
$import_path = drupal_get_path('module', 'dfs_med') . '/import/'; |
|
14
|
|
|
// Create a MigrateSource object. |
|
15
|
|
|
$this->source = new MigrateSourceCSV($import_path . 'dfs_med.nodes.brand.csv', $this->csvcolumns(), array('header_rows' => 1)); |
|
16
|
|
|
$this->destination = new MigrateDestinationNode('brand'); |
|
17
|
|
|
// Created |
|
18
|
|
|
$this->addFieldMapping('created', 'created')->defaultValue(strtotime("now")); |
|
19
|
|
|
// Logo Image |
|
20
|
|
|
$this->addFieldMapping('field_logo', 'logo'); |
|
21
|
|
|
$this->addFieldMapping('field_logo:file_replace')->defaultValue(FILE_EXISTS_REPLACE); |
|
22
|
|
|
$this->addFieldMapping('field_logo:source_dir')->defaultValue($import_path . 'images'); |
|
23
|
|
|
$this->addFieldMapping('field_logo:destination_file', 'filename'); |
|
24
|
|
|
// Splash Image |
|
25
|
|
|
$this->addFieldMapping('field_splash_image', 'splash'); |
|
26
|
|
|
$this->addFieldMapping('field_splash_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE); |
|
27
|
|
|
$this->addFieldMapping('field_splash_image:source_dir')->defaultValue($import_path . 'images'); |
|
28
|
|
|
$this->addFieldMapping('field_splash_image:destination_file', 'filename'); |
|
29
|
|
|
// Superbrand Link Image |
|
30
|
|
|
$this->addfieldmapping('field_link_image', 'link_image'); |
|
31
|
|
|
$this->addfieldmapping('field_link_image:file_replace')->defaultvalue(FILE_EXISTS_REPLACE); |
|
32
|
|
|
$this->addfieldmapping('field_link_image:source_dir')->defaultvalue($import_path . 'images'); |
|
33
|
|
|
$this->addfieldmapping('field_link_image:destination_file', 'filename'); |
|
34
|
|
|
// Superbrand Link Image |
|
35
|
|
|
$this->addfieldmapping('field_link_image_hover', 'link_image_hover'); |
|
36
|
|
|
$this->addfieldmapping('field_link_image_hover:file_replace')->defaultvalue(FILE_EXISTS_REPLACE); |
|
37
|
|
|
$this->addfieldmapping('field_link_image_hover:source_dir')->defaultvalue($import_path . 'images'); |
|
38
|
|
|
$this->addfieldmapping('field_link_image_hover:destination_file', 'filename'); |
|
39
|
|
|
// Booleans |
|
40
|
|
|
$this->addfieldmapping('field_superbrand', 'superbrand'); |
|
41
|
|
|
$this->addfieldmapping('field_greylist', 'greylist'); |
|
42
|
|
|
// Persona |
|
43
|
|
|
$this->addFieldMapping('field_persona', 'persona'); |
|
44
|
|
|
// Site Section |
|
45
|
|
|
$this->addFieldMapping('field_site_section', 'site_section')->defaultValue("Content"); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
function csvcolumns() { |
|
|
|
|
|
|
49
|
|
|
$columns[0] = array('uuid', 'UUID'); |
|
|
|
|
|
|
50
|
|
|
$columns[1] = array('title', 'Title'); |
|
51
|
|
|
$columns[2] = array('body', 'Body'); |
|
52
|
|
|
$columns[3] = array('logo', 'Logo'); |
|
53
|
|
|
$columns[4] = array('splash', 'Splash'); |
|
54
|
|
|
$columns[5] = array('link_image', 'Link Image'); |
|
55
|
|
|
$columns[6] = array('link_image_hover', 'Link Hover'); |
|
56
|
|
|
$columns[7] = array('superbrand', 'Superbrand'); |
|
57
|
|
|
$columns[8] = array('greylist', 'Greylist'); |
|
58
|
|
|
$columns[9] = array('persona', 'Persona'); |
|
59
|
|
|
return $columns; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
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.