3 namespace Drupal\taxonomy\Plugin\migrate\source\d6;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
7 use Drupal\Core\Field\FieldStorageDefinitionInterface;
10 * Drupal 6 vocabularies source from database.
13 * id = "d6_taxonomy_vocabulary",
14 * source_provider = "taxonomy"
17 class Vocabulary extends DrupalSqlBase {
22 public function query() {
23 $query = $this->select('vocabulary', 'v')
43 public function fields() {
45 'vid' => $this->t('The vocabulary ID.'),
46 'name' => $this->t('The name of the vocabulary.'),
47 'description' => $this->t('The description of the vocabulary.'),
48 'help' => $this->t('Help text to display for the vocabulary.'),
49 'relations' => $this->t('Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'),
50 'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
51 'multiple' => $this->t('Whether or not multiple terms from this vocabulary may be assigned to a node. (0 = disabled, 1 = enabled)'),
52 'required' => $this->t('Whether or not terms are required for nodes using this vocabulary. (0 = disabled, 1 = enabled)'),
53 'tags' => $this->t('Whether or not free tagging is enabled for the vocabulary. (0 = disabled, 1 = enabled)'),
54 'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
55 'parents' => $this->t("The Drupal term IDs of the term's parents."),
56 'node_types' => $this->t('The names of the node types the vocabulary may be used with.'),
63 public function prepareRow(Row $row) {
64 // Find node types for this row.
65 $node_types = $this->select('vocabulary_node_types', 'nt')
66 ->fields('nt', ['type', 'vid'])
67 ->condition('vid', $row->getSourceProperty('vid'))
70 $row->setSourceProperty('node_types', $node_types);
71 $row->setSourceProperty('cardinality', ($row->getSourceProperty('tags') == 1 || $row->getSourceProperty('multiple') == 1) ? FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED : 1);
72 return parent::prepareRow($row);
78 public function getIds() {
79 $ids['vid']['type'] = 'integer';