function Sql::getMessages
Same name and namespace in other branches
- 8.9.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getMessages()
- 10 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getMessages()
- 11.x core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getMessages()
Retrieves a traversable object of messages related to source records.
Parameters
array $source_id_values: (optional) The source identifier keyed values of the record, e.g. ['nid' => 5]. If empty (the default), all messages are retrieved.
int $level: (optional) Message severity. If NULL (the default), retrieve messages of all severities.
Return value
\Traversable Retrieves a traversable object of message objects of unspecified class. Each object has the following public properties:
- source_row_hash: the hash of the entire serialized source row data.
- message: the text of the message.
- level: one of MigrationInterface::MESSAGE_ERROR,
MigrationInterface::MESSAGE_WARNING, MigrationInterface::MESSAGE_NOTICE, MigrationInterface::MESSAGE_INFORMATIONAL.
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_mapCode
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.