function NodeType::prepareRow

Same name in this branch
  1. 11.x core/modules/node/src/Plugin/migrate/source/d6/NodeType.php \Drupal\node\Plugin\migrate\source\d6\NodeType::prepareRow()
Same name and namespace in other branches
  1. 9 core/modules/node/src/Plugin/migrate/source/d6/NodeType.php \Drupal\node\Plugin\migrate\source\d6\NodeType::prepareRow()
  2. 9 core/modules/node/src/Plugin/migrate/source/d7/NodeType.php \Drupal\node\Plugin\migrate\source\d7\NodeType::prepareRow()
  3. 8.9.x core/modules/node/src/Plugin/migrate/source/d6/NodeType.php \Drupal\node\Plugin\migrate\source\d6\NodeType::prepareRow()
  4. 8.9.x core/modules/node/src/Plugin/migrate/source/d7/NodeType.php \Drupal\node\Plugin\migrate\source\d7\NodeType::prepareRow()
  5. 10 core/modules/node/src/Plugin/migrate/source/d6/NodeType.php \Drupal\node\Plugin\migrate\source\d6\NodeType::prepareRow()
  6. 10 core/modules/node/src/Plugin/migrate/source/d7/NodeType.php \Drupal\node\Plugin\migrate\source\d7\NodeType::prepareRow()

Overrides SourcePluginBase::prepareRow

File

core/modules/node/src/Plugin/migrate/source/d7/NodeType.php, line 98

Class

NodeType
Drupal 7 Node types source from database.

Namespace

Drupal\node\Plugin\migrate\source\d7

Code

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, [
        'promote',
        'sticky',
    ]);
    $options = [];
    foreach ([
        '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', [
            '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));
    if ($menu_options = $this->variableGet('menu_options_' . $type, NULL)) {
        $row->setSourceProperty('available_menus', $menu_options);
    }
    if ($parent = $this->variableGet('menu_parent_' . $type, NULL)) {
        $row->setSourceProperty('parent', $parent . ':');
    }
    if ($this->moduleExists('comment')) {
        foreach (array_keys($this->getCommentFields()) as $field) {
            $row->setSourceProperty($field, $this->variableGet($field . '_' . $type, NULL));
        }
    }
    return parent::prepareRow($row);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.