function migrate_ui_migrate_group in Migrate 7.2
Menu callback
1 string reference to 'migrate_ui_migrate_group'
- migrate_ui_menu in migrate_ui/
migrate_ui.module - Implementation of hook_menu().
File
- migrate_ui/
migrate_ui.pages.inc, line 126 - Pages for managing migration processes.
Code
function migrate_ui_migrate_group($form, &$form_state, $group_name) {
$group = MigrateGroup::getInstance($group_name);
$build = array();
$header = array(
'machinename' => array(
'data' => t('Task'),
),
'status' => array(
'data' => t('Status'),
),
'importrows' => array(
'data' => t('Items'),
),
'imported' => array(
'data' => t('Imported'),
),
'unprocessed' => array(
'data' => t('Unprocessed'),
),
);
if (user_access(MIGRATE_ACCESS_ADVANCED)) {
$header += array(
'messages' => array(
'data' => t('Messages'),
),
'lastthroughput' => array(
'data' => t('Throughput'),
),
'lastimported' => array(
'data' => t('Last imported'),
),
);
}
$migrations = migrate_migrations();
$rows = array();
foreach ($migrations as $migration) {
$current_group = $migration
->getGroup()
->getName();
if ($current_group != $group_name) {
continue;
}
$row = array();
$has_counts = TRUE;
if (method_exists($migration, 'sourceCount')) {
$total = $migration
->sourceCount();
if ($total < 0) {
$has_counts = FALSE;
$total = t('N/A');
}
}
else {
$has_counts = FALSE;
$total = t('N/A');
}
if (method_exists($migration, 'importedCount')) {
$imported = $migration
->importedCount();
$processed = $migration
->processedCount();
}
else {
$has_counts = FALSE;
$imported = t('N/A');
}
if ($has_counts) {
$unprocessed = $total - $processed;
}
else {
$unprocessed = t('N/A');
}
$status = $migration
->getStatus();
switch ($status) {
case MigrationBase::STATUS_IDLE:
$status = t('Idle');
break;
case MigrationBase::STATUS_IMPORTING:
$status = t('Importing');
break;
case MigrationBase::STATUS_ROLLING_BACK:
$status = t('Rolling back');
break;
case MigrationBase::STATUS_STOPPING:
$status = t('Stopping');
break;
case MigrationBase::STATUS_DISABLED:
$status = t('Disabled');
break;
default:
$status = t('Unknown');
break;
}
$row['status'] = $status;
$machine_name = $migration
->getMachineName();
$row['machinename'] = l($machine_name, "admin/content/migrate/groups/{$group_name}/{$machine_name}");
$row['importrows'] = (int) $total;
$row['imported'] = (int) $imported;
$row['unprocessed'] = (int) $unprocessed;
if (user_access(MIGRATE_ACCESS_ADVANCED)) {
if (is_subclass_of($migration, 'Migration')) {
$num_messages = $migration
->messageCount();
$row['messages'] = $num_messages ? l($num_messages, "admin/content/migrate/groups/{$group_name}/{$machine_name}/messages") : 0;
}
else {
$row['messages'] = t('N/A');
}
if (method_exists($migration, 'getLastThroughput')) {
$rate = $migration
->getLastThroughput();
if ($rate == '') {
$row['lastthroughput'] = t('Unknown');
}
else {
$row['lastthroughput'] = t('@rate/min', array(
'@rate' => $rate,
));
}
}
else {
$row['lastthroughput'] = t('N/A');
}
$row['lastimported'] = check_plain($migration
->getLastImported());
}
$rows[$machine_name] = $row;
}
$build['dashboard']['migrations'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#tree' => TRUE,
'#empty' => t('No tasks are defined for this migration group.'),
);
$build['operations'] = _migrate_ui_migrate_operations();
return $build;
}