select('taxonomy_term_data', 'td') ->fields('td') ->distinct() ->orderBy('tid'); $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid'); $query->addField('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.'), '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) { // Get Field API field values. foreach (array_keys($this->getFields('taxonomy_term', $row->getSourceProperty('machine_name'))) as $field) { $tid = $row->getSourceProperty('tid'); $row->setSourceProperty($field, $this->getFieldValues('taxonomy_term', $field, $tid)); } // Find parents for this row. $parents = $this->select('taxonomy_term_hierarchy', 'th') ->fields('th', ['parent', 'tid']) ->condition('tid', $row->getSourceProperty('tid')) ->execute() ->fetchCol(); $row->setSourceProperty('parent', $parents); // Determine if this is a forum container. $forum_container_tids = $this->variableGet('forum_containers', []); $current_tid = $row->getSourceProperty('tid'); $row->setSourceProperty('is_container', in_array($current_tid, $forum_container_tids)); return parent::prepareRow($row); } /** * {@inheritdoc} */ public function getIds() { $ids['tid']['type'] = 'integer'; return $ids; } }