Drupal Comment Field

I have been using this field in  a recent project needed to migrate data to it. No migrate handler existed so I created one. Probably the easiest five minutes I have used to program Drupal.

I have submitted it too https://www.drupal.org/node/2541912

But for those looking to migrate to this field use this code


class MigrateCommentFieldHandler extends MigrateFieldHandler {

  public function __construct() {

  public function prepare($entity, array $field_info, array $instance, array $values) {
    // Setup the Field API array for saving.
    $arguments = (isset($values['arguments'])) ? $values['arguments']: array();
    $language = $this->getFieldLanguage($entity, $field_info, $arguments);
    $delta = 0;
    foreach ($values as $value) {
      $return[$language][$delta]['comment'] = $value['comment'];
      $return[$language][$delta]['created'] = $value['created'];
      $return[$language][$delta]['uid']     = $value['uid'];
    return isset($return) ? $return : NULL;


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.