Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TermEntityTranslation.php

function TermEntityTranslation::prepareRow

Overrides SourcePluginBase::prepareRow

File

core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php, line 78

Class

TermEntityTranslation
Drupal 7 taxonomy term entity translation source plugin.

Namespace

Drupal\taxonomy\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
    $tid = $row->getSourceProperty('entity_id');
    $vocabulary = $row->getSourceProperty('machine_name');
    $language = $row->getSourceProperty('language');
    // Get Field API field values.
    foreach ($this->getFields('taxonomy_term', $vocabulary) 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, NULL, $field_language));
    }
    // If the term name or term description were replaced by real fields using
    // the Drupal 7 Title module, use the fields value instead of the term name
    // or term description.
    if ($this->moduleExists('title')) {
        $name_field = $row->getSourceProperty('name_field');
        if (isset($name_field[0]['value'])) {
            $row->setSourceProperty('name', $name_field[0]['value']);
        }
        $description_field = $row->getSourceProperty('description_field');
        if (isset($description_field[0]['value'])) {
            $row->setSourceProperty('description', $description_field[0]['value']);
        }
        if (isset($description_field[0]['format'])) {
            $row->setSourceProperty('format', $description_field[0]['format']);
        }
    }
    return parent::prepareRow($row);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal