Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Sql.php

function Sql::getMessages

Overrides MigrateIdMapInterface::getMessages

File

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

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();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal