function Sql::getMessages

Same name in other branches
  1. 8.9.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getMessages()
  2. 10 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getMessages()
  3. 11.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getMessages()

Overrides MigrateIdMapInterface::getMessages

File

core/modules/migrate/src/Plugin/migrate/id_map/Sql.php, line 737

Class

Sql
Defines the sql based ID map implementation.

Namespace

Drupal\migrate\Plugin\migrate\id_map

Code

public function getMessages(array $source_id_values = [], $level = NULL) {
    $query = $this->getDatabase()
        ->select($this->messageTableName(), 'msg');
    $condition = sprintf('[msg].[%s] = [map].[%s]', $this::SOURCE_IDS_HASH, $this::SOURCE_IDS_HASH);
    $query->addJoin('LEFT', $this->mapTableName(), 'map', $condition);
    // Explicitly define the fields we want. The order will be preserved: source
    // IDs, destination IDs (if possible), and then the rest.
    foreach ($this->sourceIdFields() as $id => $column_name) {
        $query->addField('map', $column_name, "src_{$id}");
    }
    foreach ($this->destinationIdFields() as $id => $column_name) {
        $query->addField('map', $column_name, "dest_{$id}");
    }
    $query->fields('msg', [
        'msgid',
        $this::SOURCE_IDS_HASH,
        'level',
        'message',
    ]);
    if ($source_id_values) {
        $query->condition('msg.' . $this::SOURCE_IDS_HASH, $this->getSourceIdsHash($source_id_values));
    }
    if ($level) {
        $query->condition('msg.level', $level);
    }
    return $query->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.