function drush_features_export in Features 7.2
Same name and namespace in other branches
- 8.4 drush/features.drush8.inc \drush_features_export()
- 8.3 drush/features.drush8.inc \drush_features_export()
- 6 features.drush.inc \drush_features_export()
- 7 features.drush.inc \drush_features_export()
Drush command callback for 'features-export'.
Adds components to a new or existing feature module.
If the module does not exist yet, it will be created.
Return value
false|void FALSE on failure, no explicit return value otherwise.
1 call to drush_features_export()
- drush_features_add in ./
features.drush.inc - Drush command callback for 'features-add'.
File
- ./
features.drush.inc, line 562 - Features module drush integration.
Code
function drush_features_export() {
if ($args = func_get_args()) {
$module = array_shift($args);
if (empty($args)) {
return drush_set_error('', 'No components supplied.');
}
$components = _drush_features_component_list();
$options = array();
if (!drush_get_option('ignore-conflicts', FALSE)) {
$options['exported'] = FALSE;
}
$filtered_components = _drush_features_component_filter($components, $args, $options);
$items = $filtered_components['components'];
if (empty($items)) {
return drush_set_error('', 'No components to add.');
}
$items = array_map('array_keys', $items);
if (($feature = features_load_feature($module, TRUE)) && module_exists($module)) {
module_load_include('inc', 'features', 'features.export');
_features_populate($items, $feature->info, $feature->name);
_drush_features_export($feature->info, $feature->name, dirname($feature->filename));
}
elseif ($feature) {
_features_drush_set_error($module, 'FEATURES_FEATURE_NOT_ENABLED');
}
else {
// Same logic as in _drush_features_export. Should be refactored.
$destination = drush_get_option(array(
'destination',
), variable_get('features_default_export_path', FEATURES_DEFAULT_EXPORT_PATH));
$directory = isset($directory) ? $directory : $destination . '/' . $module;
drush_print(dt('Will create a new module in !dir', array(
'!dir' => $directory,
)));
if (!drush_confirm(dt('Do you really want to continue?'))) {
drush_die('Aborting.');
}
$export = _drush_features_generate_export($items, $module);
_features_populate($items, $export['info'], $export['name']);
_drush_features_export($export['info'], $module, $directory);
}
}
else {
return drush_set_error('', 'No feature name given.');
}
}