function drush_migrate_status in Migrate 6.2
Same name and namespace in other branches
- 6 migrate.drush.inc \drush_migrate_status()
- 7.2 migrate.drush.inc \drush_migrate_status()
A simplified version of the dashboard page.
File
- ./
migrate.drush.inc, line 280 - Drush support for the migrate module
Code
function drush_migrate_status($name = NULL) {
try {
$refresh = drush_get_option('refresh');
$group_option = drupal_strtolower(drush_get_option('group'));
// Validate input and load Migration(s).
if ($name) {
if ($migration = MigrationBase::getInstance($name)) {
$migrations = array(
$migration,
);
}
else {
return drush_set_error(dt('Unrecognized migration: !cn', array(
'!cn' => $name,
)));
}
}
else {
$migrations = migrate_migrations();
}
$groups = MigrateGroup::groups();
$table = array();
foreach ($groups as $group) {
if ($group_option && drupal_strtolower($group
->getName()) != $group_option) {
continue;
}
$group_members_count = 0;
foreach ($migrations as $migration) {
if ($migration
->getGroup() != $group) {
// This migration is not from this group.
continue;
}
++$group_members_count;
if ($group_members_count == 1) {
// An empty line and the headers.
$table[] = array(
'',
);
$table[] = array(
dt('Group: !name', array(
'!name' => $group
->getName(),
)),
dt('Total'),
dt('Imported'),
dt('Unimported'),
dt('Status'),
dt('Last imported'),
);
}
$has_counts = TRUE;
if (method_exists($migration, 'sourceCount')) {
$total = $migration
->sourceCount($refresh);
if ($total < 0) {
$has_counts = FALSE;
$total = dt('N/A');
}
}
else {
$has_counts = FALSE;
$total = dt('N/A');
}
if (method_exists($migration, 'importedCount')) {
$imported = $migration
->importedCount();
$processed = $migration
->processedCount();
}
else {
$has_counts = FALSE;
$imported = dt('N/A');
}
if ($has_counts) {
$unimported = $total - $processed;
}
else {
$unimported = dt('N/A');
}
$status = $migration
->getStatus();
switch ($status) {
case MigrationBase::STATUS_IDLE:
$status = dt('Idle');
break;
case MigrationBase::STATUS_IMPORTING:
$status = dt('Importing');
break;
case MigrationBase::STATUS_ROLLING_BACK:
$status = dt('Rolling back');
break;
case MigrationBase::STATUS_STOPPING:
$status = dt('Stopping');
break;
case MigrationBase::STATUS_DISABLED:
$status = dt('Disabled');
break;
default:
$status = dt('Unknown');
break;
}
$table[] = array(
$migration
->getMachineName(),
$total,
$imported,
$unimported,
$status,
$migration
->getLastImported(),
);
}
}
drush_print_table($table);
} catch (MigrateException $e) {
drush_print($e
->getMessage());
exit;
}
}