function TermEntityTranslation::prepareRow
Same name in other branches
- 9 core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d7\TermEntityTranslation::prepareRow()
- 8.9.x core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d7\TermEntityTranslation::prepareRow()
- 11.x core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d7\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\d7Code
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.