function NodeEntityTranslation::prepareRow
Same name in other branches
- 9 core/modules/node/src/Plugin/migrate/source/d7/NodeEntityTranslation.php \Drupal\node\Plugin\migrate\source\d7\NodeEntityTranslation::prepareRow()
- 10 core/modules/node/src/Plugin/migrate/source/d7/NodeEntityTranslation.php \Drupal\node\Plugin\migrate\source\d7\NodeEntityTranslation::prepareRow()
- 11.x core/modules/node/src/Plugin/migrate/source/d7/NodeEntityTranslation.php \Drupal\node\Plugin\migrate\source\d7\NodeEntityTranslation::prepareRow()
Overrides SourcePluginBase::prepareRow
File
-
core/
modules/ node/ src/ Plugin/ migrate/ source/ d7/ NodeEntityTranslation.php, line 52
Class
- NodeEntityTranslation
- Provides Drupal 7 node entity translations source plugin.
Namespace
Drupal\node\Plugin\migrate\source\d7Code
public function prepareRow(Row $row) {
$nid = $row->getSourceProperty('entity_id');
$vid = $row->getSourceProperty('revision_id');
$type = $row->getSourceProperty('type');
$language = $row->getSourceProperty('language');
// Get Field API field values.
foreach ($this->getFields('node', $type) 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('node', $field_name, $nid, $vid, $field_language));
}
// If the node title was replaced by a real field using the Drupal 7 Title
// module, use the field value instead of the node title.
if ($this->moduleExists('title')) {
$title_field = $row->getSourceProperty('title_field');
if (isset($title_field[0]['value'])) {
$row->setSourceProperty('title', $title_field[0]['value']);
}
}
return parent::prepareRow($row);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.