function drush_migrate_tools_migrate_status in Migrate Tools 8
Same name and namespace in other branches
- 8.2 migrate_tools.drush.inc \drush_migrate_tools_migrate_status()
- 8.3 migrate_tools.drush.inc \drush_migrate_tools_migrate_status()
- 8.4 migrate_tools.drush.inc \drush_migrate_tools_migrate_status()
Parameters
string $migration_names:
File
- ./
migrate_tools.drush.inc, line 133 - Command-line tools to aid performing and developing migrations.
Code
function drush_migrate_tools_migrate_status($migration_names = '') {
$group_name = drush_get_option('group');
$names_only = drush_get_option('names-only');
$migrations = drush_migrate_tools_migration_list($group_name, $migration_names);
$table = [];
// Take it one group at a time, listing the migrations within each group.
foreach ($migrations as $group_id => $migration_list) {
if ($names_only) {
$table[] = [
dt('Group: @name', array(
'@name' => $group_id,
)),
];
}
else {
$table[] = [
dt('Group: @name', array(
'@name' => $group_id,
)),
dt('Status'),
dt('Total'),
dt('Imported'),
dt('Unprocessed'),
dt('Last imported'),
];
}
foreach ($migration_list as $migration_id => $migration) {
try {
$map = $migration
->getIdMap();
$imported = $map
->importedCount();
$source_plugin = $migration
->getSourcePlugin();
} catch (Exception $e) {
drush_log(dt('Failure retrieving information on @migration: @message', [
'@migration' => $migration_id,
'@message' => $e
->getMessage(),
]));
continue;
}
try {
$source_rows = $source_plugin
->count();
// -1 indicates uncountable sources.
if ($source_rows == -1) {
$source_rows = dt('N/A');
$unprocessed = dt('N/A');
}
else {
$unprocessed = $source_rows - $map
->processedCount();
}
} catch (Exception $e) {
drush_log(dt('Could not retrieve source count from @migration', [
'@migration' => $migration_id,
]));
$source_rows = dt('N/A');
$unprocessed = dt('N/A');
}
if ($names_only) {
$table[] = [
$migration_id,
];
}
else {
$status = $migration
->getStatusLabel();
$migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported');
$last_imported = $migrate_last_imported_store
->get($migration
->id(), FALSE);
if ($last_imported) {
/** @var DateFormatter $date_formatter */
$date_formatter = \Drupal::service('date.formatter');
$last_imported = $date_formatter
->format($last_imported / 1000, 'custom', 'Y-m-d H:i:s');
}
else {
$last_imported = '';
}
$table[] = [
$migration_id,
$status,
$source_rows,
$imported,
$unprocessed,
$last_imported,
];
}
}
}
drush_print_table($table);
}