function Node::prepareRow
Same name in this branch
- 9 core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow()
Same name in other branches
- 8.9.x core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow()
- 8.9.x core/modules/node/src/Plugin/migrate/source/d7/Node.php \Drupal\node\Plugin\migrate\source\d7\Node::prepareRow()
- 10 core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow()
- 10 core/modules/node/src/Plugin/migrate/source/d7/Node.php \Drupal\node\Plugin\migrate\source\d7\Node::prepareRow()
- 11.x core/modules/node/src/Plugin/migrate/source/d6/Node.php \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow()
- 11.x core/modules/node/src/Plugin/migrate/source/d7/Node.php \Drupal\node\Plugin\migrate\source\d7\Node::prepareRow()
Overrides SourcePluginBase::prepareRow
1 call to Node::prepareRow()
- NodeComplete::prepareRow in core/
modules/ node/ src/ Plugin/ migrate/ source/ d7/ NodeComplete.php - Adds additional data to the row.
1 method overrides Node::prepareRow()
- NodeComplete::prepareRow in core/
modules/ node/ src/ Plugin/ migrate/ source/ d7/ NodeComplete.php - Adds additional data to the row.
File
-
core/
modules/ node/ src/ Plugin/ migrate/ source/ d7/ Node.php, line 133
Class
- Node
- Drupal 7 node source from database.
Namespace
Drupal\node\Plugin\migrate\source\d7Code
public function prepareRow(Row $row) {
$nid = $row->getSourceProperty('nid');
$vid = $row->getSourceProperty('vid');
$type = $row->getSourceProperty('type');
// If this entity was translated using Entity Translation, we need to get
// its source language to get the field values in the right language.
// The translations will be migrated by the d7_node_entity_translation
// migration.
$entity_translatable = $this->isEntityTranslatable('node') && (int) $this->variableGet('language_content_type_' . $type, 0) === 4;
$source_language = $this->getEntityTranslationSourceLanguage('node', $nid);
$language = $entity_translatable && $source_language ? $source_language : $row->getSourceProperty('language');
// If this is using d7_node_complete source plugin and this is a node
// using entity translation then set the language of this revision to the
// entity translation language.
if ($row->getSourceProperty('etr_created')) {
$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 and the field are
// translatable.
$field_language = $entity_translatable && $field['translatable'] ? $language : NULL;
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language));
}
// Make sure we always have a translation set.
if ($row->getSourceProperty('tnid') == 0) {
$row->setSourceProperty('tnid', $row->getSourceProperty('nid'));
}
// 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.