You are here

public function MigrateSQLMap::saveMessage in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/sqlmap.inc \MigrateSQLMap::saveMessage()

Record a message in the migration's message table.

Parameters

array $source_key: Source ID of the record in error.

string $message: The message to record.

int $level: Optional message severity (defaults to MESSAGE_ERROR).

Overrides MigrateMap::saveMessage

File

plugins/sources/sqlmap.inc, line 467
Defines a Drupal db-based implementation of MigrateMap.

Class

MigrateSQLMap
@file Defines a Drupal db-based implementation of MigrateMap.

Code

public function saveMessage($source_key, $message, $level = Migration::MESSAGE_ERROR) {

  // Source IDs as arguments.
  $count = 1;
  if (is_array($source_key)) {
    foreach ($source_key as $key_value) {
      $fields['sourceid' . $count++] = $key_value;

      // If any key value is not set, we can't save - print out and abort.
      if (!isset($key_value)) {
        Migration::displayMessage($message);
        return;
      }
    }
    $fields['level'] = $level;
    $fields['message'] = $message;
    $this->connection
      ->insert($this->messageTable)
      ->fields($fields)
      ->execute();
  }
  else {

    // TODO: What else can we do?
    // Display Message with correct level instead of default level 'error'.
    MigrationBase::saveMessage($message, $level);
  }
}