function Comment::prepareComment

Same name in this branch
  1. 9 core/modules/comment/tests/modules/d6_comment_test/src/Plugin/migrate/source/d6/Comment.php \Drupal\d6_comment_test\Plugin\migrate\source\d6\Comment::prepareComment()
Same name and namespace in other branches
  1. 8.9.x core/modules/comment/src/Plugin/migrate/source/d6/Comment.php \Drupal\comment\Plugin\migrate\source\d6\Comment::prepareComment()

Provides a BC layer for deprecated sources.

Parameters

\Drupal\migrate\Row $row: The row from the source to process.

Return value

\Drupal\migrate\Row The row object.

Throws

\Exception Passing a Row with a frozen source to this method will trigger an \Exception when attempting to set the source properties.

Deprecated

in drupal:9.3.0 and is removed from drupal:10.0.0. No direct replacement is provided.

See also

https://www.drupal.org/node/3221964

1 call to Comment::prepareComment()
Comment::prepareComment in core/modules/comment/tests/modules/d6_comment_test/src/Plugin/migrate/source/d6/Comment.php
Allow access to protected method.
1 method overrides Comment::prepareComment()
Comment::prepareComment in core/modules/comment/tests/modules/d6_comment_test/src/Plugin/migrate/source/d6/Comment.php
Allow access to protected method.

File

core/modules/comment/src/Plugin/migrate/source/d6/Comment.php, line 74

Class

Comment
Drupal 6 comment source from database.

Namespace

Drupal\comment\Plugin\migrate\source\d6

Code

protected function prepareComment(Row $row) {
  @trigger_error(__METHOD__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3221964', E_USER_DEPRECATED);
  if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
    // Comment subject visible.
    $row->setSourceProperty('field_name', 'comment');
    $row->setSourceProperty('comment_type', 'comment');
  }
  else {
    $row->setSourceProperty('field_name', 'comment_no_subject');
    $row->setSourceProperty('comment_type', 'comment_no_subject');
  }
  // In D6, status=0 means published, while in D8 means the opposite.
  // See https://www.drupal.org/node/237636.
  $row->setSourceProperty('status', !$row->getSourceProperty('status'));
  // If node did not have a language, use site default language as a fallback.
  if (!$row->getSourceProperty('language')) {
    $language_default = $this->variableGet('language_default', NULL);
    $language = $language_default ? $language_default->language : 'en';
    $row->setSourceProperty('language', $language);
  }
  return $row;
}

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