class Term

Same name in this branch
  1. 9 core/modules/taxonomy/src/Entity/Term.php \Drupal\taxonomy\Entity\Term
  2. 9 core/modules/taxonomy/src/Plugin/views/argument_validator/Term.php \Drupal\taxonomy\Plugin\views\argument_validator\Term
  3. 9 core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php \Drupal\taxonomy\Plugin\migrate\source\d7\Term
Same name and namespace in other branches
  1. 11.x core/modules/taxonomy/src/Entity/Term.php \Drupal\taxonomy\Entity\Term
  2. 11.x core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php \Drupal\taxonomy\Plugin\migrate\source\d6\Term
  3. 11.x core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php \Drupal\taxonomy\Plugin\migrate\source\d7\Term
  4. 10 core/modules/taxonomy/src/Entity/Term.php \Drupal\taxonomy\Entity\Term
  5. 10 core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php \Drupal\taxonomy\Plugin\migrate\source\d6\Term
  6. 10 core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php \Drupal\taxonomy\Plugin\migrate\source\d7\Term
  7. 8.9.x core/modules/taxonomy/src/Entity/Term.php \Drupal\taxonomy\Entity\Term
  8. 8.9.x core/modules/taxonomy/src/Plugin/views/argument_validator/Term.php \Drupal\taxonomy\Plugin\views\argument_validator\Term
  9. 8.9.x core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php \Drupal\taxonomy\Plugin\migrate\source\d6\Term
  10. 8.9.x core/modules/taxonomy/src/Plugin/migrate/source/Term.php \Drupal\taxonomy\Plugin\migrate\source\Term
  11. 8.9.x core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php \Drupal\taxonomy\Plugin\migrate\source\d7\Term

Drupal 6 taxonomy term source from database.

Available configuration keys:

  • bundle: (optional) The taxonomy vocabulary (vid) to filter terms retrieved from the source - can be an integer or an array. If omitted, all terms are retrieved.

Examples:


source:
  plugin: d6_taxonomy_term
  bundle: 0

In this example terms of vocabulary with 'vid' equal to 0 are retrieved from the source database.


source:
  plugin: d6_taxonomy_term
  bundle: [1, 3, 5]

In this example terms of vocabularies with 'vid' one of 1, 3, 5 are retrieved from the source database.

For additional configuration keys, refer to the parent classes.

@todo Support term_relation, term_synonym table if possible.

Plugin annotation


@MigrateSource(
  id = "d6_taxonomy_term",
  source_module = "taxonomy"
)

Hierarchy

Expanded class hierarchy of Term

See also

\Drupal\migrate\Plugin\migrate\source\SqlBase

\Drupal\migrate\Plugin\migrate\source\SourcePluginBase

14 string references to 'Term'
CommentTokenReplaceTest::testCommentTokenReplacement in core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php
Creates a comment, then tests the tokens generated from it.
comment_token_info in core/modules/comment/comment.tokens.inc
Implements hook_token_info().
CreateTestContentEntitiesTrait::createContent in core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php
Create several pieces of generic content.
CreateTestContentEntitiesTrait::createContentPostUpgrade in core/modules/migrate_drupal/tests/src/Traits/CreateTestContentEntitiesTrait.php
Create several pieces of generic content.
forum_views_data in core/modules/forum/forum.views.inc
Implements hook_views_data().

... See full list

File

core/modules/taxonomy/src/Plugin/migrate/source/d6/Term.php, line 48

Namespace

Drupal\taxonomy\Plugin\migrate\source\d6
View source
class Term extends DrupalSqlBase {
  
  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('term_data', 'td')
      ->fields('td')
      ->distinct()
      ->orderBy('td.tid');
    if (isset($this->configuration['bundle'])) {
      $query->condition('td.vid', (array) $this->configuration['bundle'], 'IN');
    }
    return $query;
  }
  
  /**
   * {@inheritdoc}
   */
  public function fields() {
    $fields = [
      'tid' => $this->t('The term ID.'),
      'vid' => $this->t('Existing term VID'),
      '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."),
    ];
    if (isset($this->configuration['translations'])) {
      $fields['language'] = $this->t('The term language.');
      $fields['trid'] = $this->t('Translation ID.');
    }
    return $fields;
  }
  
  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    // Find parents for this row.
    $parents = $this->select('term_hierarchy', 'th')
      ->fields('th', [
      'parent',
      'tid',
    ])
      ->condition('tid', $row->getSourceProperty('tid'))
      ->execute()
      ->fetchCol();
    $row->setSourceProperty('parent', $parents);
    return parent::prepareRow($row);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['tid']['type'] = 'integer';
    return $ids;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.