Newer
Older
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
<?php
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstance.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 field instances source from database.
*
* @MigrateSource(
* id = "d6_field_instance",
* source_provider = "content"
* )
*/
class FieldInstance extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('content_node_field_instance', 'cnfi')
->fields('cnfi', array(
'field_name',
'type_name',
'weight',
'label',
'widget_type',
'widget_settings',
'display_settings',
'description',
'widget_module',
'widget_active',
'description',
))
->fields('cnf', array(
'required',
'active',
'global_settings',
));
$query->join('content_node_field', 'cnf', 'cnf.field_name = cnfi.field_name');
$query->orderBy('type_name');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
'field_name' => $this->t('The machine name of field.'),
'type_name' => $this->t('Content type where is used this field.'),
'weight' => $this->t('Weight.'),
'label' => $this->t('A name to show.'),
'widget_type' => $this->t('Widget type.'),
'widget_settings' => $this->t('Serialize data with widget settings.'),
'display_settings' => $this->t('Serialize data with display settings.'),
'description' => $this->t('A description of field.'),
'widget_module' => $this->t('Module that implements widget.'),
'widget_active' => $this->t('Status of widget'),
'module' => $this->t('The module that provides the field.'),
);
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row, $keep = TRUE) {
// Unserialize data.
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
$display_settings = unserialize($row->getSourceProperty('display_settings'));
$global_settings = unserialize($row->getSourceProperty('global_settings'));
$row->setSourceProperty('widget_settings', $widget_settings);
$row->setSourceProperty('display_settings', $display_settings);
$row->setSourceProperty('global_settings', $global_settings);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids = array(
'field_name' => array(
'type' => 'string',
'alias' => 'cnfi',
),
'type_name' => array(
'type' => 'string',
),
);
return $ids;
}
}