You are here

public function ImportBaseComments::__construct in Import 7

General initialization of a Migration object.

Overrides Migration::__construct

File

./import.base.comments.inc, line 10
Migrations for Basic Comments.

Class

ImportBaseComments
@file Migrations for Basic Comments.

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $this->description = t('Import comments.');

  // Create a map object for tracking the relationships between source rows
  $this->map = new MigrateSQLMap($this->machineName, array(
    'subject' => array(
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
    ),
  ), MigrateDestinationComment::getKeySchema());
  $import_path = drupal_get_path('module', 'import') . '/import/';

  // Create a MigrateSource object.
  $this->source = new MigrateSourceCSV($import_path . 'import.base.comments.csv', $this
    ->csvcolumns(), array(
    'header_rows' => 1,
  ));
  $this->destination = new MigrateDestinationComment('comment_node_article');
  $this
    ->addFieldMapping('subject', 'subject');
  $this
    ->addFieldMapping('nid', 'node')
    ->sourceMigration('ImportBaseNodes');
  $this
    ->addFieldMapping('uid', 'author')
    ->sourceMigration('ImportBaseUsers');
  $this
    ->addFieldMapping('comment_body', 'body');
  $this
    ->addFieldMapping('comment_body:format')
    ->defaultValue('filtered_html');
}