function CommentType::prepareRow

Same name in other branches
  1. 9 core/modules/comment/src/Plugin/migrate/source/CommentType.php \Drupal\comment\Plugin\migrate\source\CommentType::prepareRow()
  2. 10 core/modules/comment/src/Plugin/migrate/source/CommentType.php \Drupal\comment\Plugin\migrate\source\CommentType::prepareRow()
  3. 11.x core/modules/comment/src/Plugin/migrate/source/CommentType.php \Drupal\comment\Plugin\migrate\source\CommentType::prepareRow()

Overrides SourcePluginBase::prepareRow

File

core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php, line 56

Class

CommentType
Drupal 7 comment type source from database.

Namespace

Drupal\comment\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
    $node_type = substr($row->getSourceProperty('bundle'), 13);
    $row->setSourceProperty('node_type', $node_type);
    $row->setSourceProperty('default_mode', $this->variableGet("comment_default_mode_{$node_type}", 1));
    $row->setSourceProperty('per_page', $this->variableGet("comment_default_per_page_{$node_type}", 50));
    $row->setSourceProperty('anonymous', $this->variableGet("comment_anonymous_{$node_type}", FALSE));
    $row->setSourceProperty('form_location', $this->variableGet("comment_form_location_{$node_type}", CommentItemInterface::FORM_BELOW));
    $row->setSourceProperty('preview', $this->variableGet("comment_preview_{$node_type}", TRUE));
    $row->setSourceProperty('subject', $this->variableGet("comment_subject_field_{$node_type}", TRUE));
    $label = $this->t('@node_type comment', [
        '@node_type' => $this->nodeTypes[$node_type],
    ]);
    $row->setSourceProperty('label', $label);
    return parent::prepareRow($row);
}

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