3 namespace Drupal\node\Plugin\migrate\source\d6;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
9 * Drupal 6 Node types source from database.
15 class NodeType extends DrupalSqlBase {
22 protected $teaserLength;
25 * Node preview optional / required.
29 protected $nodePreview;
32 * An array of theme settings.
36 protected $themeSettings;
41 public function query() {
42 return $this->select('node_type', 't')
64 public function fields() {
66 'type' => $this->t('Machine name of the node type.'),
67 'name' => $this->t('Human name of the node type.'),
68 'module' => $this->t('The module providing the node type.'),
69 'description' => $this->t('Description of the node type.'),
70 'help' => $this->t('Help text for the node type.'),
71 'title_label' => $this->t('Title label.'),
72 'has_body' => $this->t('Flag indicating the node type has a body field.'),
73 'body_label' => $this->t('Body label.'),
74 'min_word_count' => $this->t('Minimum word count for the body field.'),
75 'custom' => $this->t('Flag.'),
76 'modified' => $this->t('Flag.'),
77 'locked' => $this->t('Flag.'),
78 'orig_type' => $this->t('The original type.'),
79 'teaser_length' => $this->t('Teaser length'),
86 protected function initializeIterator() {
87 $this->teaserLength = $this->variableGet('teaser_length', 600);
88 $this->nodePreview = $this->variableGet('node_preview', 0);
89 $this->themeSettings = $this->variableGet('theme_settings', []);
90 return parent::initializeIterator();
96 public function prepareRow(Row $row) {
97 $row->setSourceProperty('teaser_length', $this->teaserLength);
98 $row->setSourceProperty('node_preview', $this->nodePreview);
100 $type = $row->getSourceProperty('type');
101 $source_options = $this->variableGet('node_options_' . $type, ['promote', 'sticky']);
103 foreach (['promote', 'sticky', 'status', 'revision'] as $item) {
104 $options[$item] = in_array($item, $source_options);
106 $row->setSourceProperty('options', $options);
107 $submitted = isset($this->themeSettings['toggle_node_info_' . $type]) ? $this->themeSettings['toggle_node_info_' . $type] : FALSE;
108 $row->setSourceProperty('display_submitted', $submitted);
110 if ($default_node_menu = $this->variableGet('menu_default_node_menu', NULL)) {
111 $row->setSourceProperty('available_menus', [$default_node_menu]);
112 $row->setSourceProperty('parent', $default_node_menu . ':');
114 return parent::prepareRow($row);
120 public function getIds() {
121 $ids['type']['type'] = 'string';