function ctools_drush_export_info in Chaos Tool Suite (ctools) 7
Drush callback: Export info.
@params $table_names Each argument will be taken as a CTools exportable table name.
1 string reference to 'ctools_drush_export_info'
- ctools_drush_command in drush/
ctools.drush.inc - Implements hook_drush_command().
File
- drush/
ctools.drush.inc, line 371 - CTools Drush commands.
Code
function ctools_drush_export_info() {
// Collect array of table names from args.
$table_names = func_get_args();
// Get format option to allow for alternative output.
$format = drush_get_option('format', FALSE);
$tables_only = drush_get_option('tables-only', FALSE);
$filter = drush_get_option('filter', FALSE);
$export_module = drush_get_option('module', FALSE);
$load = (bool) $filter || $export_module;
// Get info on these tables, or all tables if none specified.
$info = _ctools_drush_export_info($table_names, $load);
$schemas = $info['schemas'];
$exportables = $info['exportables'];
if (empty($exportables)) {
drush_log(dt('There are no exportables available.'), 'warning');
return;
}
// Filter by export module.
if (is_string($export_module)) {
$exportables = _ctools_drush_export_module_filter($exportables, $export_module);
}
if (empty($exportables)) {
drush_log(dt('There are no exportables matching this criteria.'), 'notice');
return;
}
$exportable_counts = _ctools_drush_count_exportables($exportables);
// Only use array keys if --tables-only option is set.
if ($tables_only) {
$exportables = array_keys($exportables);
}
// Use format from --format option if it's present, and send to drush_format.
if ($format) {
// Create array with all exportable info and counts in one.
$output = array(
'exportables' => $exportables,
'count' => $exportable_counts,
);
drush_print(drush_format($output, NULL, $format));
}
else {
$header = $tables_only ? array() : array(
dt('Module'),
dt('Base table'),
dt('Exportables'),
);
$rows = array();
foreach ($exportables as $table => $info) {
if (is_array($info)) {
$row = array(
$schemas[$table]['module'],
$table,
// Machine name is better for this?
shellColours::getColouredOutput(implode("\n", array_keys($info)), 'light_green') . "\n",
);
$rows[] = $row;
}
else {
$rows[] = array(
$info,
);
}
}
if (!empty($rows)) {
drush_print("\n");
array_unshift($rows, $header);
drush_print_table($rows, TRUE, array(
20,
20,
));
drush_print(dt('Total exportables found: !total', array(
'!total' => $exportable_counts['total'],
)));
foreach ($exportable_counts['exportables'] as $table_name => $count) {
drush_print(dt('!table_name (!count)', array(
'!table_name' => $table_name,
'!count' => $count,
)), 2);
}
drush_print("\n");
}
}
}