You are here

public function WineCommentMigration::__construct in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 migrate_example/wine.inc \WineCommentMigration::__construct()

General initialization of a Migration object.

Overrides AdvancedExampleMigration::__construct

File

migrate_example/wine.inc, line 1439
Advanced migration examples. These serve two purposes:

Class

WineCommentMigration

Code

public function __construct($arguments) {
  parent::__construct($arguments);
  $this->description = 'Comments about wines';
  $query = db_select('migrate_example_wine_comment', 'wc')
    ->fields('wc', array(
    'commentid',
    'comment_parent',
    'name',
    'mail',
    'accountid',
    'body',
    'wineid',
    'subject',
    'commenthost',
    'userpage',
    'posted',
    'lastchanged',
  ))
    ->orderBy('comment_parent');
  $this->source = new MigrateSourceSQL($query);
  $this->destination = new MigrateDestinationComment('comment_node_migrate_example_wine');
  $this->map = new MigrateSQLMap($this->machineName, array(
    'commentid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
  ), MigrateDestinationComment::getKeySchema());

  // Mapped fields
  $this
    ->addSimpleMappings(array(
    'name',
    'subject',
    'mail',
  ));
  $this
    ->addFieldMapping('status')
    ->defaultValue(COMMENT_PUBLISHED);
  $this
    ->addFieldMapping('nid', 'wineid')
    ->sourceMigration('WineWine');
  $this
    ->addFieldMapping('uid', 'accountid')
    ->sourceMigration('WineUser')
    ->defaultValue(0);
  $this
    ->addFieldMapping('pid', 'comment_parent')
    ->sourceMigration('WineComment')
    ->description('Parent comment');
  $this
    ->addFieldMapping('comment_body', 'body');
  $this
    ->addFieldMapping('hostname', 'commenthost');
  $this
    ->addFieldMapping('created', 'posted');
  $this
    ->addFieldMapping('changed', 'lastchanged');
  $this
    ->addFieldMapping('homepage', 'userpage');

  // No unmapped source fields
  // Unmapped destination fields
  $this
    ->addUnmigratedDestinations(array(
    'comment_body:format',
    'language',
    'thread',
  ));
  $this
    ->removeFieldMapping('pathauto');
}