VocabularyPerType.php in Drupal 8
File
core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
View source
<?php
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
class VocabularyPerType extends Vocabulary {
public function query() {
$query = parent::query();
$query
->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
$query
->fields('nt', [
'type',
]);
return $query;
}
public function prepareRow(Row $row) {
$i18ntaxonomy_vocab = $this
->variableGet('i18ntaxonomy_vocabulary', []);
$vid = $row
->getSourceProperty('vid');
$i18ntaxonomy_vocabulary = FALSE;
if (array_key_exists($vid, $i18ntaxonomy_vocab)) {
$i18ntaxonomy_vocabulary = $i18ntaxonomy_vocab[$vid];
}
$row
->setSourceProperty('i18ntaxonomy_vocabulary', $i18ntaxonomy_vocabulary);
return parent::prepareRow($row);
}
public function getIds() {
$ids['vid']['type'] = 'integer';
$ids['vid']['alias'] = 'nt';
$ids['type']['type'] = 'string';
return $ids;
}
}
Classes
Name |
Description |
VocabularyPerType |
Gets all the vocabularies based on the node types that have Taxonomy enabled. |