function drush_migrate_tools_migrate_messages in Migrate Tools 8.3
Same name and namespace in other branches
- 8 migrate_tools.drush.inc \drush_migrate_tools_migrate_messages()
- 8.2 migrate_tools.drush.inc \drush_migrate_tools_migrate_messages()
- 8.4 migrate_tools.drush.inc \drush_migrate_tools_migrate_messages()
Parameters
string $migration_id:
File
- ./
migrate_tools.drush.inc, line 376 - Command-line tools to aid performing and developing migrations.
Code
function drush_migrate_tools_migrate_messages($migration_id) {
/** @var MigrationInterface $migration */
$migration = \Drupal::service('plugin.manager.migration')
->createInstance($migration_id);
if ($migration) {
$map = $migration
->getIdMap();
$first = TRUE;
$table = [];
foreach ($map
->getMessageIterator() as $row) {
unset($row->msgid);
if ($first) {
// @todo: Ideally, replace sourceid* with source key names. Or, should
// getMessageIterator() do that?
foreach ($row as $column => $value) {
$table[0][] = $column;
}
$first = FALSE;
}
$table[] = (array) $row;
}
if (empty($table)) {
drush_log(dt('No messages for this migration'), 'status');
}
else {
if (drush_get_option('csv')) {
foreach ($table as $row) {
fputcsv(STDOUT, $row);
}
}
else {
$widths = [];
foreach ($table[0] as $header) {
$widths[] = strlen($header) + 1;
}
drush_print_table($table, TRUE, $widths);
}
}
}
else {
drush_log(dt('Migration @id does not exist', [
'@id' => $migration_id,
]), 'error');
}
}