public function NodeType::prepareRow in Zircon Profile 8
Same name in this branch
- 8 core/modules/node/src/Plugin/migrate/source/d6/NodeType.php \Drupal\node\Plugin\migrate\source\d6\NodeType::prepareRow()
- 8 core/modules/node/src/Plugin/migrate/source/d7/NodeType.php \Drupal\node\Plugin\migrate\source\d7\NodeType::prepareRow()
Same name and namespace in other branches
- 8.0 core/modules/node/src/Plugin/migrate/source/d7/NodeType.php \Drupal\node\Plugin\migrate\source\d7\NodeType::prepareRow()
Add 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/ node/ src/ Plugin/ migrate/ source/ d7/ NodeType.php, line 76 - Contains \Drupal\node\Plugin\migrate\source\d7\NodeType.
Class
- NodeType
- Drupal 7 Node types source from database.
Namespace
Drupal\node\Plugin\migrate\source\d7Code
public function prepareRow(Row $row) {
$row
->setSourceProperty('teaser_length', $this->teaserLength);
$row
->setSourceProperty('node_preview', $this->nodePreview);
$type = $row
->getSourceProperty('type');
$source_options = $this
->variableGet('node_options_' . $type, array(
'promote',
'sticky',
));
$options = array();
foreach (array(
'promote',
'sticky',
'status',
'revision',
) as $item) {
$options[$item] = in_array($item, $source_options);
}
$row
->setSourceProperty('options', $options);
// Don't create a body field until we prove that this node type has one.
$row
->setSourceProperty('create_body', FALSE);
if ($this
->moduleExists('field')) {
// Find body field for this node type.
$body = $this
->select('field_config_instance', 'fci')
->fields('fci', array(
'data',
))
->condition('entity_type', 'node')
->condition('bundle', $row
->getSourceProperty('type'))
->condition('field_name', 'body')
->execute()
->fetchAssoc();
if ($body) {
$row
->setSourceProperty('create_body', TRUE);
$body['data'] = unserialize($body['data']);
$row
->setSourceProperty('body_label', $body['data']['label']);
}
}
$row
->setSourceProperty('display_submitted', $this
->variableGet('node_submitted_' . $type, TRUE));
return parent::prepareRow($row);
}