You are here

public function MigrateDestinationPrivatemsg::import in Migrate Extras 6.2

Same name and namespace in other branches
  1. 7.2 privatemsg.inc \MigrateDestinationPrivateMsg::import()

Import a single private message.

Parameters

$message: Message object to build.

$row: Raw source data object

Return value

array Array of key fields (mid only in this case) of the message that was saved if successful. FALSE on failure.

Overrides MigrateDestination::import

File

./privatemsg.inc, line 103
Support for the Privatemsg module.

Class

MigrateDestinationPrivatemsg
Destination class implementing

Code

public function import(stdClass $message, stdClass $row) {
  $migration = Migration::currentMigration();

  // Updating previously-migrated content?
  if (isset($row->migrate_map_destid1)) {
    $message->mid = $row->migrate_map_destid1;
  }
  if ($migration
    ->getSystemOfRecord() == Migration::DESTINATION) {
    if (!isset($message->mid)) {
      throw new MigrateException(t('System-of-record is DESTINATION, but no destination uid provided'));
    }
  }

  //$this->prepare($message, $row);

  //$new_thread = $message->new_thread;
  migrate_instrument_start('privatemsg_save');
  $newmessage = $this
    ->_privatemsg_migrate_save($message);
  migrate_instrument_stop('privatemsg_save');
  if ($newmessage->success) {

    //$this->complete($newmessage, $row);
    $return = isset($newmessage->mid) ? array(
      $newmessage->mid,
    ) : FALSE;
  }
  else {
    $return = FALSE;
  }
  return $return;
}