public function TermEntityTranslation::prepareRow in Drupal 9
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d7\TermEntityTranslation::prepareRow()
- 10 core/modules/taxonomy/src/Plugin/migrate/source/d7/TermEntityTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d7\TermEntityTranslation::prepareRow()
Adds additional data to the row.
Parameters
\Drupal\migrate\Row $row: The row object.
Return value
bool FALSE if this row needs to be skipped.
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']);
}
}
// Determine if this is a forum container.
$forum_container_tids = $this
->variableGet('forum_containers', []);
$row
->setSourceProperty('is_container', in_array($tid, $forum_container_tids));
return parent::prepareRow($row);
}