public function Sql::getMessages in Drupal 8
Same name and namespace in other branches
- 9 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()
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
1 call to Sql::getMessages()
- Sql::getMessageIterator in core/
modules/ migrate/ src/ Plugin/ migrate/ id_map/ Sql.php - Retrieves an iterator over messages relate to source records.
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ id_map/ Sql.php, line 689
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();
}