select('taxonomy_term_data', 'td') ->fields('td') ->condition('et.entity_type', 'taxonomy_term') ->condition('et.source', '', '<>') ->orderBy('tid'); $query->innerJoin('entity_translation', 'et', 'et.entity_id = td.tid'); $query->fields('et'); $query->leftJoin('taxonomy_vocabulary', 'tv', 'tv.vid = td.vid'); $query->fields('tv', ['machine_name']); if (isset($this->configuration['bundle'])) { $query->condition('tv.machine_name', (array) $this->configuration['bundle'], 'IN'); } return $query; } /** * {@inheritdoc} */ public function fields() { $fields = [ 'tid' => $this->t('The term ID.'), 'vid' => $this->t('Existing term VID'), 'machine_name' => $this->t('Vocabulary machine name'), 'name' => $this->t('The name of the term.'), 'revision_id' => $this->t('Revision ID'), 'language' => $this->t('Term translation language'), 'source' => $this->t('Term translation source language'), 'description' => $this->t('The term description.'), 'weight' => $this->t('Weight'), 'parent' => $this->t("The Drupal term IDs of the term's parents."), 'format' => $this->t("Format of the term description."), ]; return $fields; } /** * {@inheritdoc} */ public function prepareRow(Row $row) { $language = $row->getSourceProperty('language'); $tid = $row->getSourceProperty('tid'); drush_print('-- '. $language ."\t".$tid."\t".$row->getSourceProperty('name')); // vocabulary machine name $machine_name = $row->getSourceProperty('machine_name'); $revid = $row->getSourceProperty('revision_id'); // Get Field API field values. foreach ($this->getFields('taxonomy_term', $machine_name) as $field_name => $field) { // Ensure we're using the right language if the entity is translatable. $field_language = $field['translatable'] ? $language : NULL; $row->setSourceProperty($field_name, $this->getFieldValues('taxonomy_term', $field_name, $tid, $revid, $field_language)); } // If the node title was replaced by a real field using the Drupal 7 Title // module, use the field value instead of the node title. if ($this->moduleExists('title')) { $name_field = $row->getSourceProperty('name_field'); if (isset($name_field[0]['value'])) { $row->setSourceProperty('name', $name_field[0]['value']); } } return parent::prepareRow($row); } /** * {@inheritdoc} */ public function getIds() { $ids['tid']['type'] = 'integer'; return $ids; } }