Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CommentEntityTranslation.php

function CommentEntityTranslation::prepareRow

Overrides SourcePluginBase::prepareRow

File

core/modules/comment/src/Plugin/migrate/source/d7/CommentEntityTranslation.php, line 49

Class

CommentEntityTranslation
Drupal 7 comment entity translation source plugin.

Namespace

Drupal\comment\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
    $cid = $row->getSourceProperty('entity_id');
    $language = $row->getSourceProperty('language');
    $node_type = $row->getSourceProperty('node_type');
    $comment_type = 'comment_node_' . $node_type;
    // Get Field API field values.
    foreach ($this->getFields('comment', $comment_type) as $field_name => $field) {
        // Ensure we're using the right language if the entity is translatable.
        $field_language = $field['translatable'] ? $language : NULL;
        $row->setSourceProperty($field_name, $this->getFieldValues('comment', $field_name, $cid, NULL, $field_language));
    }
    // If the comment subject was replaced by a real field using the Drupal 7
    // Title module, use the field value instead of the comment subject.
    if ($this->moduleExists('title')) {
        $subject_field = $row->getSourceProperty('subject_field');
        if (isset($subject_field[0]['value'])) {
            $row->setSourceProperty('subject', $subject_field[0]['value']);
        }
    }
    return parent::prepareRow($row);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal