3 namespace Drupal\taxonomy\Plugin\migrate\source\d6;
5 use Drupal\migrate\Row;
8 * Gets all the vocabularies based on the node types that have Taxonomy enabled.
11 * id = "d6_taxonomy_vocabulary_per_type",
12 * source_module = "taxonomy"
15 class VocabularyPerType extends Vocabulary {
20 public function query() {
21 $query = parent::query();
22 $query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
23 $query->fields('nt', ['type']);
30 public function prepareRow(Row $row) {
31 // Get the i18n taxonomy translation setting for this vocabulary.
32 // 0 - No multilingual options
33 // 1 - Localizable terms. Run through the localization system.
34 // 2 - Predefined language for a vocabulary and its terms.
35 // 3 - Per-language terms, translatable (referencing terms with different
36 // languages) but not localizable.
37 $i18ntaxonomy_vocab = $this->variableGet('i18ntaxonomy_vocabulary', NULL);
38 $vid = $row->getSourceProperty('vid');
39 $i18ntaxonomy_vocabulary = FALSE;
40 if (array_key_exists($vid, $i18ntaxonomy_vocab)) {
41 $i18ntaxonomy_vocabulary = $i18ntaxonomy_vocab[$vid];
43 $row->setSourceProperty('i18ntaxonomy_vocabulary', $i18ntaxonomy_vocabulary);
44 return parent::prepareRow($row);
50 public function getIds() {
51 $ids['vid']['type'] = 'integer';
52 $ids['vid']['alias'] = 'nt';
53 $ids['type']['type'] = 'string';