3 namespace Drupal\taxonomy\Plugin\migrate\source\d6;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
9 * Taxonomy term source from database.
11 * @todo Support term_relation, term_synonym table if possible.
14 * id = "d6_taxonomy_term",
15 * source_provider = "taxonomy"
18 class Term extends DrupalSqlBase {
23 public function query() {
24 $query = $this->select('term_data', 'td')
29 if (isset($this->configuration['bundle'])) {
30 $query->condition('td.vid', (array) $this->configuration['bundle'], 'IN');
39 public function fields() {
41 'tid' => $this->t('The term ID.'),
42 'vid' => $this->t('Existing term VID'),
43 'name' => $this->t('The name of the term.'),
44 'description' => $this->t('The term description.'),
45 'weight' => $this->t('Weight'),
46 'parent' => $this->t("The Drupal term IDs of the term's parents."),
48 if (isset($this->configuration['translations'])) {
49 $fields['language'] = $this->t('The term language.');
50 $fields['trid'] = $this->t('Translation ID.');
58 public function prepareRow(Row $row) {
59 // Find parents for this row.
60 $parents = $this->select('term_hierarchy', 'th')
61 ->fields('th', ['parent', 'tid'])
62 ->condition('tid', $row->getSourceProperty('tid'))
65 $row->setSourceProperty('parent', $parents);
67 return parent::prepareRow($row);
73 public function getIds() {
74 $ids['tid']['type'] = 'integer';