function _drush_features_generate_export in Features 7.2
Helper function for _drush_feature_export.
Parameters
array $info: The feature info associative array.
string $module_name: Optional. The name for the exported module.
Return value
array Export array.
2 calls to _drush_features_generate_export()
- drush_features_export in ./
features.drush.inc - Drush command callback for 'features-export'.
- _drush_features_export in ./
features.drush.inc - Write a module to the site dir.
File
- ./
features.drush.inc, line 777 - Features module drush integration.
Code
function _drush_features_generate_export(&$info, &$module_name) {
module_load_include('inc', 'features', 'features.export');
$export = features_populate($info, $module_name);
if (!features_load_feature($module_name)) {
$export['name'] = $module_name;
}
// Set the feature version, if the --version-set or --version-increment option
// is passed.
if ($version = drush_get_option(array(
'version-set',
))) {
preg_match('/^(?P<core>\\d+\\.x)-(?P<major>\\d+)\\.(?P<patch>\\d+)-?(?P<extra>\\w+)?$/', $version, $matches);
if (!isset($matches['core'], $matches['major'])) {
drush_die(dt('Please enter a valid version with core and major version number. Example: !example', array(
'!example' => '7.x-1.0',
)));
}
$export['version'] = $version;
}
elseif ($version = drush_get_option(array(
'version-increment',
))) {
// Determine current version and increment it.
$export_load = features_export_prepare($export, $module_name);
$version = $export_load['version'];
$version_explode = explode('.', $version);
$version_minor = array_pop($version_explode);
// Increment minor version number if numeric or not a dev release.
if (is_numeric($version_minor) || strpos($version_minor, 'dev') !== strlen($version_minor) - 3) {
// Check for prefixed versions (alpha, beta, rc).
if (ctype_digit($version_minor)) {
++$version_minor;
}
else {
// Split version number parts.
$pattern = '/([0-9]-[a-z]+([0-9]+))/';
$matches = array();
preg_match($pattern, $version_minor, $matches);
$number = array_pop($matches);
++$number;
$pattern = '/[0-9]+$/';
$version_minor = preg_replace($pattern, $number, $version_minor);
}
}
array_push($version_explode, $version_minor);
// Rebuild version string.
$version = implode('.', $version_explode);
$export['version'] = $version;
}
return $export;
}