function drush_feeds_enable in Feeds 7.2
Enables a set of Feeds importers.
File
- ./
feeds.drush.inc, line 637 - Drush commands for Feeds module.
Code
function drush_feeds_enable() {
$all = array_keys(feeds_importer_load_all(TRUE));
$enabled = array_keys(feeds_importer_load_all());
$missing = array_diff(func_get_args(), $all);
$to_enable = array_diff(func_get_args(), $enabled, $missing);
$already_enabled = array_intersect(func_get_args(), $enabled);
if ($missing) {
drush_print(dt('The following importers are missing: !importers', array(
'!importers' => implode(', ', $missing),
)));
}
if ($already_enabled) {
drush_print(dt('The following importers are already enabled: !importers', array(
'!importers' => implode(', ', $already_enabled),
)));
}
if ($to_enable) {
drush_print(dt('The following importers will be enabled: !importers', array(
'!importers' => implode(', ', $to_enable),
)));
}
elseif (count(func_get_args()) == 0) {
return drush_set_error(dt('Please specify a space delimited list of importers to enable.'));
}
else {
return drush_print(dt('There are no importers to enable.'));
}
if (!drush_confirm(dt('Do you really want to continue?'))) {
return drush_log(dt('Aborting.'), 'ok');
}
$disabled = variable_get('default_feeds_importer', array());
foreach ($to_enable as $importer_id) {
unset($disabled[$importer_id]);
drush_log(dt("The importer '!importer' has been enabled.", array(
'!importer' => $importer_id,
)), 'ok');
}
variable_set('default_feeds_importer', $disabled);
feeds_cache_clear();
}