function _drush_features_export in Features 6
Same name and namespace in other branches
- 7.2 features.drush.inc \_drush_features_export()
- 7 features.drush.inc \_drush_features_export()
Write a module to the site dir.
Parameters
$requests: An array of the context requested in this export.
$module_name: Optional. The name for the exported module.
3 calls to _drush_features_export()
- drush_features_add in ./
features.drush.inc - Add a component to a features module.
- drush_features_export in ./
features.drush.inc - Create a feature module based on a list of components.
- drush_features_update in ./
features.drush.inc - Update an existing feature module.
File
- ./
features.drush.inc, line 415 - Features module drush integration.
Code
function _drush_features_export($stub, $dependencies, $module_name = NULL, $directory = NULL) {
$root = drush_get_option(array(
'r',
'root',
), drush_locate_root());
if ($root) {
$directory = isset($directory) ? $directory : 'sites/all/modules/' . $module_name;
if (is_dir($directory)) {
drush_print(dt('Module appears to already exist in !dir', array(
'!dir' => $directory,
)));
if (!drush_confirm(dt('Do you really want to continue?'))) {
drush_die('Aborting.');
}
}
else {
drush_op('mkdir', $directory);
}
if (is_dir($directory)) {
drupal_flush_all_caches();
module_load_include('inc', 'features', 'features.export');
$export = features_populate($stub, $dependencies, $module_name);
if (!feature_load($module_name)) {
$export['name'] = $module_name;
}
$files = features_export_render($export, $module_name, TRUE);
foreach ($files as $extension => $file_contents) {
if (!in_array($extension, array(
'module',
'info',
))) {
$extension .= '.inc';
}
drush_op('file_put_contents', "{$directory}/{$module_name}.{$extension}", $file_contents);
}
drush_log(dt("Created module: !module in !directory", array(
'!module' => $module_name,
'!directory' => $directory,
)), 'ok');
}
else {
drush_die(dt('Couldn\'t create directory !directory', array(
'!directory' => $directory,
)));
}
}
else {
drush_die(dt('Couldn\'t locate site root'));
}
}