| 1 |
<?php
|
| 2 |
// $Id: $
|
| 3 |
|
| 4 |
function import_manager_drush_help($section) {
|
| 5 |
switch ($section) {
|
| 6 |
case 'drush:import manager list':
|
| 7 |
return dt('List available imports.');
|
| 8 |
|
| 9 |
case 'drush:import manager run':
|
| 10 |
return dt('Run an import.');
|
| 11 |
}
|
| 12 |
}
|
| 13 |
|
| 14 |
function import_manager_drush_command() {
|
| 15 |
return array(
|
| 16 |
'import manager list' => array(
|
| 17 |
'callback' => 'import_manager_drush_list',
|
| 18 |
'description' => 'List available imports.',
|
| 19 |
'arguments' => array(
|
| 20 |
'[module]' => 'Optional module name.',
|
| 21 |
),
|
| 22 |
),
|
| 23 |
'import manager run' => array(
|
| 24 |
'callback' => 'import_manager_drush_run',
|
| 25 |
'description' => 'Run an import.',
|
| 26 |
'arguments' => array(
|
| 27 |
'function' => 'Function to run.',
|
| 28 |
'[...]' => 'Additional arguments.',
|
| 29 |
),
|
| 30 |
),
|
| 31 |
);
|
| 32 |
}
|
| 33 |
|
| 34 |
function import_manager_drush_list($module = NULL) {
|
| 35 |
if (is_null($module)) {
|
| 36 |
$modules = module_implements('imports');
|
| 37 |
}
|
| 38 |
else {
|
| 39 |
$modules = array($module);
|
| 40 |
}
|
| 41 |
foreach ($modules as $module) {
|
| 42 |
$info = drupal_parse_info_file(drupal_get_path('module', $module) .'/'. $module .'.info');
|
| 43 |
foreach (module_invoke($module, 'imports') as $name => $group) {
|
| 44 |
drush_print('');
|
| 45 |
drush_print($info['name'] . ' - ' . $name);
|
| 46 |
$functions = array();
|
| 47 |
foreach ($group as $function => $options) {
|
| 48 |
$functions[] = array(
|
| 49 |
$function,
|
| 50 |
$options['title'],
|
| 51 |
);
|
| 52 |
}
|
| 53 |
drush_print_table($functions);
|
| 54 |
}
|
| 55 |
}
|
| 56 |
}
|
| 57 |
|
| 58 |
function import_manager_drush_run() {
|
| 59 |
$args = func_get_args();
|
| 60 |
$function = array_shift($args);
|
| 61 |
import_manager_run($function, $args);
|
| 62 |
}
|