Version 1
[yaffs-website] / web / core / modules / taxonomy / src / Plugin / migrate / source / d6 / VocabularyPerType.php
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
new file mode 100644 (file)
index 0000000..40a0094
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\taxonomy\Plugin\migrate\source\d6;
+
+/**
+ * Gets all the vocabularies based on the node types that have Taxonomy enabled.
+ *
+ * @MigrateSource(
+ *   id = "d6_taxonomy_vocabulary_per_type",
+ *   source_provider = "taxonomy"
+ * )
+ */
+class VocabularyPerType extends Vocabulary {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function query() {
+    $query = parent::query();
+    $query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
+    $query->fields('nt', ['type']);
+    return $query;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getIds() {
+    $ids['vid']['type'] = 'integer';
+    $ids['vid']['alias'] = 'nt';
+    $ids['type']['type'] = 'string';
+    return $ids;
+  }
+
+}